Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: go-chi/chi
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.1.2
Choose a base ref
...
head repository: go-chi/chi
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.0.0
Choose a head ref
Loading
Showing with 737 additions and 250 deletions.
  1. +32 −0 .github/workflows/ci.yml
  2. +0 −20 .travis.yml
  3. +90 −1 CHANGELOG.md
  4. +14 −0 Makefile
  5. +123 −53 README.md
  6. +6 −15 _examples/chi.svg
  7. +1 −1 _examples/custom-handler/main.go
  8. +2 −2 _examples/custom-method/main.go
  9. +2 −2 _examples/fileserver/main.go
  10. +7 −3 _examples/graceful/main.go
  11. +2 −2 _examples/hello-world/main.go
  12. +2 −2 _examples/limits/main.go
  13. +2 −2 _examples/logging/main.go
  14. +3 −3 _examples/rest/main.go
  15. +4 −4 _examples/rest/routes.json
  16. +1 −1 _examples/router-walk/main.go
  17. +2 −2 _examples/todos-resource/main.go
  18. +1 −1 _examples/todos-resource/todos.go
  19. +1 −1 _examples/todos-resource/users.go
  20. +2 −2 _examples/versions/main.go
  21. +2 −2 chi.go
  22. +6 −21 context.go
  23. +3 −0 go.mod
  24. +2 −1 middleware/basic_auth.go
  25. +28 −0 middleware/clean_path.go
  26. +1 −1 middleware/compress_test.go
  27. +1 −1 middleware/content_charset_test.go
  28. +1 −1 middleware/content_encoding_test.go
  29. +6 −8 middleware/content_type.go
  30. +82 −0 middleware/content_type_test.go
  31. +1 −1 middleware/get_head.go
  32. +1 −1 middleware/get_head_test.go
  33. +20 −1 middleware/logger.go
  34. +34 −0 middleware/logger_test.go
  35. +5 −7 middleware/middleware_test.go
  36. +3 −3 middleware/profiler.go
  37. +1 −1 middleware/realip_test.go
  38. +3 −3 middleware/request_id_test.go
  39. +1 −1 middleware/route_headers.go
  40. +11 −5 middleware/strip.go
  41. +72 −3 middleware/strip_test.go
  42. +5 −5 middleware/throttle.go
  43. +5 −5 middleware/throttle_test.go
  44. +2 −2 middleware/url_format.go
  45. +50 −0 middleware/url_format_test.go
  46. +1 −1 middleware/value.go
  47. +7 −22 middleware/wrap_writer.go
  48. +0 −9 middleware/wrap_writer_test.go
  49. +34 −21 mux.go
  50. +41 −2 mux_test.go
  51. +5 −4 tree.go
  52. +6 −1 tree_test.go
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on: [push, pull_request]
name: Test
jobs:
test:
env:
GOPATH: ${{ github.workspace }}
GO111MODULE: off

defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}

strategy:
matrix:
go-version: [1.14.x, 1.15.x, 1.16.x]
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
with:
path: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}
- name: Test
run: |
go get -d -t ./...
make test
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

91 changes: 90 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,95 @@
# Changelog

## v5.0.0 (2021-02-27)

- chi v5, `github.com/go-chi/chi/v5` introduces the adoption of Go's SIV to adhere to the current state-of-the-tools in Go.
- chi v1.5.x did not work out as planned, as the Go tooling is too powerful and chi's adoption is too wide.
The most responsible thing to do for everyone's benefit is to just release v5 with SIV, so I present to you all,
chi v5 at `github.com/go-chi/chi/v5`. I hope someday the developer experience and ergonomics I've been seeking
will still come to fruition in some form, see https://github.com/golang/go/issues/44550
- History of changes: see https://github.com/go-chi/chi/compare/v1.5.4...v5.0.0


## v1.5.4 (2021-02-27)

- Undo prior retraction in v1.5.3 as we prepare for v5.0.0 release
- History of changes: see https://github.com/go-chi/chi/compare/v1.5.3...v1.5.4


## v1.5.3 (2021-02-21)

- Update go.mod to go 1.16 with new retract directive marking all versions without prior go.mod support
- History of changes: see https://github.com/go-chi/chi/compare/v1.5.2...v1.5.3


## v1.5.2 (2021-02-10)

- Reverting allocation optimization as a precaution as go test -race fails.
- Minor improvements, see history below
- History of changes: see https://github.com/go-chi/chi/compare/v1.5.1...v1.5.2


## v1.5.1 (2020-12-06)

- Performance improvement: removing 1 allocation by foregoing context.WithValue, thank you @bouk for
your contribution (https://github.com/go-chi/chi/pull/555). Note: new benchmarks posted in README.
- `middleware.CleanPath`: new middleware that clean's request path of double slashes
- deprecate & remove `chi.ServerBaseContext` in favour of stdlib `http.Server#BaseContext`
- plus other tiny improvements, see full commit history below
- History of changes: see https://github.com/go-chi/chi/compare/v4.1.2...v1.5.1


## v1.5.0 (2020-11-12) - now with go.mod support

`chi` dates back to 2016 with it's original implementation as one of the first routers to adopt the newly introduced
context.Context api to the stdlib -- set out to design a router that is faster, more modular and simpler than anything
else out there -- while not introducing any custom handler types or dependencies. Today, `chi` still has zero dependencies,
and in many ways is future proofed from changes, given it's minimal nature. Between versions, chi's iterations have been very
incremental, with the architecture and api being the same today as it was originally designed in 2016. For this reason it
makes chi a pretty easy project to maintain, as well thanks to the many amazing community contributions over the years
to who all help make chi better (total of 86 contributors to date -- thanks all!).

Chi has been an labour of love, art and engineering, with the goals to offer beautiful ergonomics, flexibility, performance
and simplicity when building HTTP services with Go. I've strived to keep the router very minimal in surface area / code size,
and always improving the code wherever possible -- and as of today the `chi` package is just 1082 lines of code (not counting
middlewares, which are all optional). As well, I don't have the exact metrics, but from my analysis and email exchanges from
companies and developers, chi is used by thousands of projects around the world -- thank you all as there is no better form of
joy for me than to have art I had started be helpful and enjoyed by others. And of course I use chi in all of my own projects too :)

For me, the asthetics of chi's code and usage are very important. With the introduction of Go's module support
(which I'm a big fan of), chi's past versioning scheme choice to v2, v3 and v4 would mean I'd require the import path
of "github.com/go-chi/chi/v4", leading to the lengthy discussion at https://github.com/go-chi/chi/issues/462.
Haha, to some, you may be scratching your head why I've spent > 1 year stalling to adopt "/vXX" convention in the import
path -- which isn't horrible in general -- but for chi, I'm unable to accept it as I strive for perfection in it's API design,
aesthetics and simplicity. It just doesn't feel good to me given chi's simple nature -- I do not foresee a "v5" or "v6",
and upgrading between versions in the future will also be just incremental.

I do understand versioning is a part of the API design as well, which is why the solution for a while has been to "do nothing",
as Go supports both old and new import paths with/out go.mod. However, now that Go module support has had time to iron out kinks and
is adopted everywhere, it's time for chi to get with the times. Luckily, I've discovered a path forward that will make me happy,
while also not breaking anyone's app who adopted a prior versioning from tags in v2/v3/v4. I've made an experimental release of
v1.5.0 with go.mod silently, and tested it with new and old projects, to ensure the developer experience is preserved, and it's
largely unnoticed. Fortunately, Go's toolchain will check the tags of a repo and consider the "latest" tag the one with go.mod.
However, you can still request a specific older tag such as v4.1.2, and everything will "just work". But new users can just
`go get github.com/go-chi/chi` or `go get github.com/go-chi/chi@latest` and they will get the latest version which contains
go.mod support, which is v1.5.0+. `chi` will not change very much over the years, just like it hasn't changed much from 4 years ago.
Therefore, we will stay on v1.x from here on, starting from v1.5.0. Any breaking changes will bump a "minor" release and
backwards-compatible improvements/fixes will bump a "tiny" release.

For existing projects who want to upgrade to the latest go.mod version, run: `go get -u github.com/go-chi/chi@v1.5.0`,
which will get you on the go.mod version line (as Go's mod cache may still remember v4.x). Brand new systems can run
`go get -u github.com/go-chi/chi` or `go get -u github.com/go-chi/chi@latest` to install chi, which will install v1.5.0+
built with go.mod support.

My apologies to the developers who will disagree with the decisions above, but, hope you'll try it and see it's a very
minor request which is backwards compatible and won't break your existing installations.

Cheers all, happy coding!


---


## v4.1.2 (2020-06-02)

- fix that handles MethodNotAllowed with path variables, thank you @caseyhadden for your contribution
@@ -23,7 +113,6 @@
- middleware.Recoverer: a bit prettier
- History of changes: see https://github.com/go-chi/chi/compare/v4.0.4...v4.1.0


## v4.0.4 (2020-03-24)

- middleware.Recoverer: new pretty stack trace printing (https://github.com/go-chi/chi/pull/496)
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
all:
@echo "**********************************************************"
@echo "** chi build tool **"
@echo "**********************************************************"


test:
go clean -testcache && $(MAKE) test-router && $(MAKE) test-middleware

test-router:
go test -race -v .

test-middleware:
go test -race -v ./middleware
Loading