Commit Graph

274 Commits

Author SHA1 Message Date
Matt Silverlock
e67b3c02c7 Remove TravisCI badge (#503) 2019-07-20 13:14:35 -07:00
Franklin Harding
7a1bf406d6 [docs] Add documentation for using mux to serve a SPA (#493)
* Add documentation for using mux to serve a SPA

* r -> router to prevent shadowing

* Expand SPA acronym

* BrowserRouter link

* Add more comments to explain how the spaHandler.ServeHTTP method works
2019-07-20 07:53:35 -07:00
Christian Muehlhaeuser
eab9c4f3d2 Simplify code (#501)
Use a single append call instead of a ranged for loop.
2019-07-20 07:49:38 -07:00
Christian Muehlhaeuser
50fbc3e7fb Avoid unnecessary conversion (#502)
No need to convert here.
2019-07-20 07:48:32 -07:00
Matt Silverlock
d83b6ffe49 Update config.yml (#495)
* Update config.yml

* Update config.yml
2019-07-01 13:26:33 -07:00
Matt Silverlock
00bdffe0f3 Update stale.yml (#494) v1.7.3 2019-06-29 21:17:52 -07:00
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
d70f7b4baa Delete ISSUE_TEMPLATE.md (#492) 2019-06-29 11:01:59 -07:00
Franklin Harding
48f941fa99 Use subtests for middleware tests (#478)
* Use subtests for middleware tests
* Don't use subtests for MiddlewareAdd
2019-06-29 10:24:12 -07:00
Matt Silverlock
64954673e9 Delete .travis.yml (#490) 2019-06-28 16:07:30 -07:00
Franklin Harding
4248f5cd87 Fix nil panic in authentication middleware example (#489) 2019-06-28 08:33:07 -07:00
Matt Silverlock
212aa90d7c [WIP] Create CircleCI config (#484)
* [ci] Create CircleCI config
* Fix typos in container versions
* Add CircleCI badge
2019-06-24 09:05:39 -07:00
M@
ed099d4238 host:port matching does not require a :port to be specified.
In lieu of checking the template pattern on every Match request, a bool is added to the routeRegexp, and set
if the routeRegexp is a host AND there is no ":" in the template. I dislike extending the type, but I'd dislike
doing a string match on every single Match, even more.
v1.7.2
2019-05-16 17:20:44 -07:00
sekky0905
c5c6c98bc2 [build] Remove sudo setting from travis.yml (#462) v1.7.1 2019-03-16 06:32:43 -07:00
Benjamin Boudreau
15a353a636 adding Router.Name to create new Route (#457) 2019-02-28 10:12:03 -08:00
Benjamin Boudreau
8eaa9f1309 fix go1.12 go vet usage (#458) 2019-02-28 09:36:07 -08:00
Souvik Haldar
8559a4f775 [docs] typo (#454) 2019-02-17 07:38:49 -08:00
moeryomenko
a7962380ca replace rr.HeaderMap by rr.Header() (#443) v1.7.0 2019-01-25 10:05:53 -06:00
Tim
797e653da6 Call WriteHeader after setting other header(s) in the example (#442)
From the docs: Changing the header map after a call to WriteHeader (or
Write) has no effect unless the modified headers are
trailers.
2019-01-25 05:41:49 -06:00
Gregor Weckbecker
08e7f807d3 Ignore ErrNotFound while matching Subrouters (#438)
MatchErr is set by the router to ErrNotFound if no route matches. If
no route of a Subrouter matches the error can by safely ignored. This
implementation only ignores these errors and does not ignore other
errors like ErrMethodMismatch.
2019-01-08 08:29:30 -06:00
santsai
f3ff42f93a getHost() now returns full host & port information (#383)
Previously, getHost only returned the host. As it now returns the
port as well, any .Host matches on a route will need to be updated
to also support matching on the port for cases where the port is
non default, eg: 80 for http or 443 for https.
2019-01-04 07:08:45 -08:00
tomare
ef912dd76e [bugfix] Clear matchErr when traversing subrouters.
Previously, when searching for a match, matchErr would be erroneously set, and prevent middleware from running (no match == no middleware runs).

This fix clears matchErr before traversing the next subrouter in a multi-subrouter router.
2018-12-27 16:42:16 -08:00
Raees
a31c1782bf Replace domain.com with example.com (#434)
Because domain.com is an actual business, example.com should be used for example purposes.
2018-12-25 08:41:17 -08:00
Michael Li
6137e193cd remove redundant code that remove support gorilla/context (#427)
* remove redundant code that remove support gorilla/context

* backward compatible for remove redundant code
2018-12-17 09:42:43 -05:00
Matt Silverlock
d2b5d13b92 Update and rename stale to stale.yml (#425) 2018-12-08 12:40:53 -08:00
Matt Silverlock
419fd9fe2a Add stalebot config (#424) 2018-12-07 08:41:48 -08:00
Joe Wilner
758eb64354 Improve subroute configuration propagation #422
* Pull out common shared `routeConf` so that config is pushed on to child
routers and routes.
* Removes obsolete usages of `parentRoute`
* Add tests defining compositional behavior
* Exercise `copyRouteConf` for posterity
2018-12-07 09:48:26 -06:00
kanozec
3d80bc801b Use subtests in mux_test.go (#415) 2018-10-30 08:25:28 -07:00
Nguyen Ngoc Trung (Steven)
521ea7b17d Use constant for 301 status code in regexp.go (#412) 2018-10-23 19:08:00 -07:00
Kamil Kisiel
deb579d6e0 README.md: Update site URL 2018-10-12 08:31:51 -07:00
Matt Silverlock
9e1f5955c0 Always run on the latest stable Go version. (#402)
Only run vet on the latest Go version.
2018-09-03 08:43:05 -07:00
Matt Silverlock
cf6680bc62 Create release-drafter.yml (#399) 2018-09-02 15:36:45 -07:00
Franklin Harding
8771f97498 Drop support for Go < 1.7: remove gorilla/context (#391)
* Drop support for Go < 1.7: remove gorilla/context
* Remove Go < 1.7 from Travis CI config
* Remove unneeded _native from context files
2018-09-02 15:22:40 -07:00
Shalom Yerushalmy
962c5bed07 Add 1.11 to build in travis (#398) 2018-08-30 07:23:24 -07:00
Kamil Kisiel
e48e440e4c Add test for multiple calls to Name().
Fixes #394
2018-08-07 00:52:56 -07:00
Kamil Kisiel
815b8c6a26 Clarify behaviour of Name method if called multiple times. 2018-08-07 00:50:18 -07:00
Matt Silverlock
cb4698366a Update LICENSE & AUTHORS files. (#386) 2018-06-05 14:15:56 -07:00
Jim Kalafut
e0b5abaaae Initialize user map (#371) 2018-05-26 15:17:21 -07:00
Matt Silverlock
c85619274f [deps] Add go.mod for versioned Go (#376) 2018-05-17 10:36:23 -07:00
Matt Silverlock
e3702bed27 [docs] Improve docstrings for middleware, skipclean (#375) v1.6.2 2018-05-12 20:22:33 -07:00
Sean Walberg
fdeb7bc314 [docs] Doc fix for testing variables in path (#374)
The example in the README does not pass the request through a mux therefore the request variables from the path are never populated. Update the sample to create a minimum viable router to use.

Fixes #373
2018-05-12 20:09:30 -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
Matt Silverlock
b57cb1605f [build] Update Go versions; add 1.10.x (#364) 2018-04-16 13:45:19 -07:00
brandon-height
94231ffd98 Fix table-driven example documentation (#363)
Prior to this change, the example documentation
found in the README.md has an errant code which
won't work in the table-driven code example.

This change modifies the variable name from `t` to `tc`
so it does not conflict with the `t *testing.T` struct
definition.

* Adds a range clause to the `for` statement
* Modifies `for` statement scope to use `tc.shouldPass`, and `tc.routeVariable`

Doc: https://github.com/gorilla/mux#testing-handlers
2018-04-03 11:23:30 -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
Geon Kim
07ba1fd60e Modify http status code to variable in README (#350)
* Modify http status code to variable

* Modify doc

* Modify README
2018-02-25 21:11:51 -08:00
Geon Kim
d284fd8421 Modify 403 status code to const variable (#349)
* Modify http status code to variable

* Modify doc
2018-02-25 08:08:54 -08:00
Kamil Kisiel
c0091a0299 Create authentication middleware example. (#340)
* Create authentication middleware example.

For #339

* Fix example test filename.
2018-01-19 23:58:19 -08:00
Franklin Harding
0fdf828bb2 [docs] Clarify SetURLVars (#335)
* [docs] Clarify SetURLVars

Clarify in documentation that SetURLVars does not modify the given
*htttp.Request, provide an example of usage.

* Short and sweet function doc, example test.
2018-01-19 22:28:49 -08:00