6 Commits

Author SHA1 Message Date
Franklin Harding
0534769016 Improve CORS Method Middleware (#477)
* More sensical CORSMethodMiddleware

* Only sets Access-Control-Allow-Methods on valid preflight requests
* Does not return after setting the Access-Control-Allow-Methods header
* Does not append OPTIONS header to Access-Control-Allow-Methods
regardless of whether there is an OPTIONS method matcher
* Adds tests for the listed behavior

* Add example for CORSMethodMiddleware

* Do not check for preflight and add documentation to the README

* Use http.MethodOptions instead of "OPTIONS"

* Add link to CORSMethodMiddleware section to readme

* Add test for unmatching route methods

* Rename CORS Method Middleware to Handling CORS Requests in README

* Link CORSMethodMiddleware in README to godoc

* Break CORSMethodMiddleware doc into bullets for readability

* Add comment about specifying OPTIONS to example in README for CORSMethodMiddleware

* Document cURL command used for testing CORS Method Middleware

* Update comment in example to "Handle the request"

* Add explicit comment about OPTIONS matchers to CORSMethodMiddleware doc

* Update circleci config to only check gofmt diff on latest go version

* Break up gofmt and go vet checks into separate steps.

* Use canonical circleci config
2019-06-29 13:52:29 -07:00
Matt Silverlock
e3702bed27 [docs] Improve docstrings for middleware, skipclean (#375) 2018-05-12 20:22:33 -07:00
Franklin Harding
5e55a4adb8 Add CORSMethodMiddleware (#366)
CORSMethodMiddleware sets the Access-Control-Allow-Methods response header
on a request, by matching routes based only on paths. It also handles
OPTIONS requests, by settings Access-Control-Allow-Methods, and then
returning without calling the next HTTP handler.
2018-05-11 18:30:14 -07:00
Matt Silverlock
ded0c29b24 Fix linter issues (docs) (#370) 2018-04-30 20:11:36 -07:00
Johan Svensson
4dbd923b0c Make Use() variadic (#355)
Enables neater syntax when chaining several middleware functions.
2018-03-14 09:31:26 -07:00
Roberto Santalla
53c1911da2 [feat] Add middleware support as discussed in #293 (#294)
* mux.Router now has a `Use` method that allows you to add middleware to request processing.
2018-01-16 09:23:47 -08:00