68 Commits

Author SHA1 Message Date
adam magued
e8f24969d5
feat(routergroup): include HTTP QUERY method in Any (#4878)
Signed-off-by: AdamMagued <adamismailmageud@gmail.com>
2026-10-10 12:16:17 +08:00
Gaurav Patil
b1f77cf536
feat(gin): add support for the HTTP QUERY method (RFC 10008) (#4806)
* feat: add support for the HTTP QUERY method (RFC 10008)

Add a QUERY shortcut on RouterGroup, a gin.MethodQuery constant and a
gin.IQueryRoutes interface for callers that only hold an IRoutes value.

QUERY is deliberately kept out of IRoutes and out of Any:

- Adding a method to IRoutes would break every type outside of Gin that
  implements it, such as test doubles and wrappers.
- Leaving Any untouched keeps existing catch-all routes matching exactly
  the methods they matched before. Match([]string{gin.MethodQuery, ...})
  covers the case where QUERY is wanted alongside other methods.

MethodQuery is declared in Gin because the standard library does not
provide http.MethodQuery yet. The value stays correct once it does.

Ref #4721

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix(router): remove duplicate QUERY method

- Consolidate QUERY into the existing router method after merging master
- Preserve the MethodQuery constant and request body documentation

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2026-09-19 14:20:37 +08:00
Ruben Pari
b52df1fe77
docs: document panic conditions in Handle, StaticFS, and Bind (#4797)
Handle panics on invalid HTTP method, StaticFS panics when relativePath
contains URL parameters, and Bind panics when given a pointer. These
panic conditions are reasonable startup-time guards but were not
documented, making the crash risk undiscoverable without reading source.

Fixes #4594
2026-09-16 21:26:35 +08:00
Jia-ben00
2a1a14ff37
feat(router): add QUERY method shortcut for RFC 10008 (#4830)
* feat(router): add QUERY method shortcut for RFC 10008

Add a QUERY() router method as a shortcut for Handle("QUERY", path, handlers),
following the same pattern as GET, POST, HEAD and other HTTP method shortcuts.

The QUERY method is defined by RFC 10008 and allows sending a query in the
request body, similar to GET but with a body. Go's net/http does not yet
expose an http.MethodQuery constant, so the literal string "QUERY" is used.

Closes #4721

* style(router): format QUERY method test

- Remove an extra blank line to satisfy gofmt.

---------

Co-authored-by: Jia-ben00 <316397950+Jia-ben00@users.noreply.github.com>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2026-09-16 21:24:33 +08:00
Mahan Adhikari
8e07d37c63
fix: Correct typos, improve documentation clarity, and remove dead code (#4511)
* fix: correct typos and improve documentation clarity

- Fix typo "Oupps" to "Oops" in recovery test panic messages
- Fix confusing documentation in Bind() and ShouldBind() methods
  that incorrectly stated "JSON or XML as a JSON input"
- Remove double period in StaticFileFS documentation comment
- Remove unused ErrorTypeNu constant that had duplicate comment
  with ErrorTypeAny and was never used in the codebase

* tech: Fix the pull request routing link
2026-02-13 13:54:14 +08:00
Johannes Eiglsperger
8791c96960
feat(fs): Export, test and document OnlyFilesFS (#3939) 2024-05-08 15:47:54 +08:00
Alireza (Pure)
e02ae6ae61
chore(router): match method added to routergroup for multiple HTTP methods supporting (#3464) 2023-02-06 15:46:42 +08:00
Jesse
51aea73ba0
fix: modify interface check way (#3327) 2022-10-20 00:49:19 +08:00
Konstantin Runov
814cd188eb
FIX TYPO: Gin by default useR -> ... useS (#3324) 2022-09-18 21:59:57 +08:00
Dave Rolsky
2ae6157049
Fix typos in RouterGroup method docs (#3302)
There were a number of spots referring to a variable named "handle" that should be "handlers".
2022-08-31 14:34:33 +08:00
thinkerou
b04917c53e
chore: upgrade golangci-lint and fix golangci-lint error (#3278) 2022-08-15 21:38:20 +08:00
thinkerou
4b68a5f12a
chore: update go.mod and remove space from copyright (#3158)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-28 10:42:28 +08:00
thinkgo
417b142703
feat: add StaticFileFS (#2749)
* RouterGroup.StaticFileFS added
add StaticFileFS ad README

* fix Static content mistake

* update README `tab`
improve StaticFile and StaticFileFS code, use staticFileHandler
2022-03-18 09:52:23 +08:00
bestgopher
3757142584
Update routergroup.go (#3056) 2022-02-14 14:39:57 +08:00
heige
eb75ce0ff5
adjust the routergroup Any method (#2701) 2021-10-24 09:31:13 +08:00
Lanco
f96678cb6b
use assert1 func (#2783) 2021-07-11 14:38:45 +08:00
heige
f1da692fbd
RouterGroup.Handle regular match optimization of http method (#2685)
Co-authored-by: thinkerou <thinkerou@gmail.com>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2021-04-21 08:24:55 +08:00
bestgopher
c9b8535817
Rename some variables (#2393) 2020-05-25 20:13:09 +08:00
thinkerou
d5f12ac6d7
use http method constant (#2155)
* use http method constant

* fix typo
2019-11-29 07:50:49 +08:00
Shamus Taylor
aabaccbba2 Close files opened in static file handler (#2118)
* Close files opened in static file handler

* Do not use defer
2019-10-31 22:52:02 +08:00
Sai
4a23c4f7b9 fix #1804 which is caused by calling middleware twice. (#1805)
Fix: https://github.com/gin-gonic/gin/issues/1804

`allNoRoute` contains middlewares such as `gin.Logger`, `gin.Recovery`, so on.  The correct code is to use `noRoute`.

cc: @MetalBreaker
2019-03-11 10:52:47 +08:00
John Bampton
d8fb18c33b Fix case of GitHub (#1726) 2018-12-31 09:02:53 +08:00
thinkerou
98c7ac7202
fix bug (#1682) 2018-12-05 13:36:49 +08:00
MetalBreaker
b97ccf3a43 Router: Route StaticFS() not found to Router's NoRoute() (#1663)
Closes #1220
2018-11-26 23:01:51 +08:00
Barnabus
7a374f9a47 Fix typos (#1626) 2018-11-05 14:17:04 +08:00
田欧
f2cd3fcb2a chore: fix typo and add a little anotation (#1562) 2018-09-20 11:53:58 +08:00
田欧
6db092f778 chore: add some annotations (#1550)
ref #1075 should all annotations and can close #1075 .
2018-09-15 15:21:54 +08:00
田欧
6c6d97ba2e remove hardcode instead of http status value (#1411) 2018-06-26 17:21:32 +08:00
MW Lim
c2f083fc95 minor typo in routergroup.go (#1360) 2018-05-31 11:41:45 +08:00
田欧
a8fa424ae5 update comment (#1057) 2017-08-16 11:55:50 +08:00
田欧
d535fcd598 separate type define (#975) 2017-07-05 02:47:36 -05:00
Manu Mtz-Almeida
e8bc8f48e9 Merge branch 'master' into develop
Conflicts:
	README.md
	gin.go
	routergroup.go
2015-08-16 18:38:13 +02:00
Manu Mtz-Almeida
fc5e355724 BasePath is not longer an exported field, but a method instead 2015-07-08 04:27:23 +02:00
Javier Provecho Fernandez
7c0c427b2d Fix #252 typo (middlewares -> middleware) 2015-07-03 20:12:01 +02:00
Manu Mtz-Almeida
8f3047814e Comments + IRoutes + IRouter + unexported AbortIndex 2015-07-02 20:24:54 +02:00
Manu Mtz-Almeida
9268afb15d Cosmetic changes 2015-06-26 16:05:09 +02:00
Manu Mtz-Almeida
9e44079756 RoutesInterface includes Group() 2015-06-26 16:01:35 +02:00
Steeve Chailloux
4238c5b83d make routesInterface exported 2015-06-23 15:57:21 -05:00
Manu Mtz-Almeida
4998bc2b2e Fixes pipeline API 2015-06-11 01:02:38 +02:00
Manu Mtz-Almeida
86c75ce95d Adds collection pipeline pattern 2015-06-10 17:10:34 +02:00
Manu Mtz-Almeida
92475baba6 Adds more units tests 2015-06-04 04:50:40 +02:00
Manu Mtz-Almeida
1228b03914 Fixing some unit tests 2015-05-31 18:35:28 +02:00
Manu Mtz-Almeida
aa9078bc73 More benchmarks 2015-05-31 15:55:10 +02:00
Manu Mtz-Almeida
cd92bf4385 Adds panic when using too many handlers 2015-05-31 04:34:21 +02:00
Manu Mtz-Almeida
98951c44aa Return 404 when listing empty directory 2015-05-24 17:03:44 +02:00
Manu Mtz-Almeida
fcfe65685a Refactored StaticFS()
- different approach to disable directory listing.
2015-05-24 16:29:55 +02:00
Manu Mtz-Almeida
cac77e04e3 Adds option for listing directory files + better unit tests 2015-05-21 17:01:13 +02:00
Manu Mtz-Almeida
72f200ac56 Adds StaticFile() 2015-05-21 16:59:58 +02:00
Manu Mtz-Almeida
c2abae6840 debugPrintRoute() is called in the lowest layer of abstraction 2015-05-20 11:32:39 +02:00
Manu Mtz-Almeida
138e4b49bf Using WrapH() internally. 2015-05-20 11:30:22 +02:00