Commit graph

636 commits

Author SHA1 Message Date
Peter Kieltyka
c416831d21 typo 2021-02-10 08:09:51 -05:00
Peter Kieltyka
de5f84b91c docs, the basics.. 2021-02-06 19:37:02 -05:00
Peter Kieltyka
00cc734b67 router with empty routes but MethodNotAllowed is still valid 2021-02-06 18:40:53 -05:00
Eduardo Sachser
423901dfd5
Fixing RegisterMethod method value generation (#573)
* Fix: RegisterMethod registering first method with same value as mTRACE

* Len of methods must not be greater than IntSize - 2
2021-02-05 20:28:56 -05:00
C H
c936bbd658
lint (#577)
* - fix naming
- fix 301 (http.StatusMovedPermanently)

* - fix naming
- fix 301 (http.StatusMovedPermanently)
2021-02-05 20:26:50 -05:00
Tommi Rantala
82aabd6698
Fix data race in TestServerBaseContext (#575)
Update the test server config before starting it, to fix data race in
TestServerBaseContext:

$ go test -race
==================
WARNING: DATA RACE
Read at 0x00c00041c068 by goroutine 500:
  net/http.(*Server).Serve()
      /usr/lib/golang/src/net/http/server.go:2919 +0x325
  net/http/httptest.(*Server).goServe.func1()
      /usr/lib/golang/src/net/http/httptest/server.go:308 +0xd3

Previous write at 0x00c00041c068 by goroutine 1298:
  github.com/go-chi/chi.TestServerBaseContext()
      /home/rantala/git/chi/mux_test.go:1687 +0x202
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:1050 +0x1eb

Goroutine 500 (running) created at:
  net/http/httptest.(*Server).goServe()
      /usr/lib/golang/src/net/http/httptest/server.go:306 +0x69
  net/http/httptest.(*Server).Start()
      /usr/lib/golang/src/net/http/httptest/server.go:132 +0x15c
  net/http/httptest.NewServer()
      /usr/lib/golang/src/net/http/httptest/server.go:105 +0x1a2
  github.com/go-chi/chi.TestServerBaseContext()
      /home/rantala/git/chi/mux_test.go:1686 +0x144
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:1050 +0x1eb

Goroutine 1298 (running) created at:
  testing.(*T).Run()
      /usr/lib/golang/src/testing/testing.go:1095 +0x537
  testing.runTests.func1()
      /usr/lib/golang/src/testing/testing.go:1339 +0xa6
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:1050 +0x1eb
  testing.runTests()
      /usr/lib/golang/src/testing/testing.go:1337 +0x594
  testing.(*M).Run()
      /usr/lib/golang/src/testing/testing.go:1252 +0x2ff
  main.main()
      _testmain.go:128 +0x223
==================
--- FAIL: TestServerBaseContext (0.00s)
    testing.go:965: race detected during execution of test
FAIL
2021-02-05 20:26:32 -05:00
Peter Kieltyka
894714a52f router with empty routes but NotFound is still valid 2021-02-05 20:22:16 -05:00
Masaya Watanabe
681ea79f56
Fix: validate empty path param (#567)
Thanks @matsuyoshi30
2020-12-24 12:28:05 -05:00
0daryo
ec0754d719
Refactor param type combine (#565) 2020-12-23 12:43:22 -05:00
Bernhard Reisenberger
32e49a13fe
logger: support websocket upgrade (#562)
Co-authored-by: Bernhard Reisenberger <bernhard@nimbusec.com>
2020-12-11 07:23:58 -05:00
Peter Kieltyka
f61ec8cf7c
v1.5 release with go.mod support (#560) 2020-12-06 13:50:37 -05:00
Peter Kieltyka
7b755d4741 Update middleware test to remove x/net/http2 use 2020-12-05 15:33:45 -05:00
Peter Kieltyka
b58e609d0a Update graceful example using ServerBaseContext 2020-12-05 14:59:26 -05:00
Peter Kieltyka
bf722e8cfa Deprecate ServerBaseContext in favour of stdlib http.Server#BaseContext 2020-12-05 14:57:51 -05:00
Peter Kieltyka
9e829149a5 middleware.RedirectSlashes: slight update from last PR 2020-12-05 14:09:26 -05:00
Rafael Valiev
87e5387928
Fix RedirectSlashes, Closes #504 (#505)
* Add test for wrong redirects

* Fix redirect issue

* Fix test error

* Fix linter

* Fix linter
2020-12-05 14:07:21 -05:00
Peter Kieltyka
3479a89b95 middleware.Logger: by default disable colors for Windows runtime 2020-12-05 13:37:37 -05:00
Stephen Afam-Osemene
38aa4a9079
Make stripslashes middleware work with other routers (#539) 2020-12-05 13:05:38 -05:00
Peter Kieltyka
484787e732 README 2020-12-05 12:52:07 -05:00
Peter Kieltyka
042ce0e7de README, and other comments 2020-12-05 12:50:55 -05:00
Bernardo Pericacho Sánchez
8afb3c57ef
AllowContentType middleware refactor and tests (#470)
* AllowContentType middleware refactor and tests

* Use struct in the map and just check existence
2020-12-05 12:25:23 -05:00
Peter Kieltyka
655cfcdb18 naming convention fix from PR 2020-12-05 10:38:37 -05:00
Derek Bassett
73938b5d1a
Chops the Suffix rather than the Prefix (#531)
* Chop the Suffix rather then the Prefix so behavior matches how the middleware is described in the comments.

* goimports
2020-12-05 10:36:39 -05:00
Peter Kieltyka
81b0a6f7ed Func placement 2020-11-29 17:41:01 -05:00
Peter Kieltyka
364c5647f7 Update comments and benchmarks after 1 allocation optimization, thanks @bouk 2020-11-29 17:34:05 -05:00
Bouke van der Bijl
8391bdb4da
Remove one allocation by foregoing context.WithValue (#555)
Instead of we can make Context implement the context.Context interface
directly through a private type, which just implements the Value method.
2020-11-29 17:12:28 -05:00
Peter Kieltyka
5fe292dcdc middleware: CleanPath to remove double slashes from request path 2020-11-29 15:53:00 -05:00
Peter Kieltyka
872fc7a381 Rename buildRouteHandler to updateRouteHandler 2020-11-29 15:50:06 -05:00
Peter Kieltyka
3b1ab84c7d Update chi logo 2020-11-27 19:58:17 -05:00
Peter Kieltyka
f36dec5699 Update chi logo 2020-11-27 19:55:16 -05:00
Peter Kieltyka
3c4c04dd99
Out with Travis. Enter Github Actions CI (#554) 2020-11-24 22:06:26 -05:00
Peter Kieltyka
eeee8a2d34
Cleanup wildcard URLParam which connects the subrouter (#553)
* Cleanup wildcard URLParam which connects the subrouter

* Add comment about subrouter logic
2020-11-24 21:12:32 -05:00
Peter Kieltyka
f3105d4f53
Prevent mounting a nil handler (#552)
* Prevent mounting a nil handler

* Prevent Route() of a nil subrouter
2020-11-24 14:57:13 -05:00
Fabio Berchtold
062dcf6306
use ConstantTimeCompare for password comparison (#549) 2020-11-17 12:45:04 -05:00
AJ ONeal
314d7e7e3f
Update README.md (#541)
Be explicit about using v4.x tags. Addresses https://github.com/go-chi/chi/issues/462.
2020-11-12 18:31:05 +01:00
Stuart Jansen
2e5656d201
Make README godoc link more useful (#546)
I was initially confused by difference between what I was seeing in the documentation versus using Chi, until I realized I was looking at 4 year old docs.

As far as I can tell, there isn't a perfect solution here. The pragmatic solution seems to be to ask the reader to pick the version they want to see.
2020-10-11 10:01:19 -04:00
Peter Kieltyka
c4e3a750be README 2020-10-09 20:51:05 -04:00
Peter Kieltyka
cf97bef8b1 README 2020-07-08 08:28:43 -04:00
David C
d6855b8512
Respond with 429 when throttled (#528) 2020-07-08 08:16:06 -04:00
Peter Kieltyka
df86a5eddf README, update godoc links to go.pkg.dev 2020-07-02 23:20:37 -04:00
AJ ONeal
7cb71d651d
README, godoc links to middleware (#516) 2020-07-02 23:13:10 -04:00
alresvor
3950456604
remove unnecessary type conversions (#523)
name                              old time/op    new time/op
Mux/route:/sup/123/foo/this-8     1.24µs ± 0%    1.99µs ± 0%

name                              old alloc/op   new alloc/op
Mux/route:/sup/123/foo/this-8     456B ± 0%      448B ± 0%

name                              old allocs/op  new allocs/op
Mux/route:/sup/123/foo/this-8     4.00 ± 0%      3.00 ± 0%
2020-06-26 10:06:54 -04:00
Peter Kieltyka
86f9a6e7ce Release v4.1.2 2020-06-02 15:02:25 -04:00
Peter Kieltyka
fdba45dc93 cosmetic, move public methods to top of source file 2020-06-02 10:54:52 -04:00
Peter Kieltyka
234035e0fd README, add note on go-chi/httprate middleware 2020-05-30 20:36:42 -04:00
Julian R Figueroa
e7728c6d4b
Replace wildcards correctly in RoutePattern (#515) 2020-05-30 19:05:35 -04:00
Casey Hadden
5704d7ee98
fix: handle methodnotallowed with path variables (#512) 2020-05-22 09:51:03 -04:00
Peter Kieltyka
ccb4c33d6a README 2020-05-17 17:14:23 -04:00
Peter Kieltyka
2333c5c4e4
Trying Github sponsor thing 2020-04-16 11:11:09 -04:00
Peter Kieltyka
1fafc30c1d Release v4.1.1 2020-04-16 08:17:06 -04:00