summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gorilla/mux/doc.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-05-18 07:32:31 -0700
committerGitHub <noreply@github.com>2018-05-18 07:32:31 -0700
commitd5e1f7e2982c2fcc888ccac550b34095efbee217 (patch)
treed8cfe7e3f47537cce92b26a1b32b9081f0bd7993 /vendor/github.com/gorilla/mux/doc.go
parentd3ead7dc8535f8fa5b175686cc1f7669c8b1648b (diff)
downloadchat-d5e1f7e2982c2fcc888ccac550b34095efbee217.tar.gz
chat-d5e1f7e2982c2fcc888ccac550b34095efbee217.tar.bz2
chat-d5e1f7e2982c2fcc888ccac550b34095efbee217.zip
Upgrading server dependency. (#8807)
Diffstat (limited to 'vendor/github.com/gorilla/mux/doc.go')
-rw-r--r--vendor/github.com/gorilla/mux/doc.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/vendor/github.com/gorilla/mux/doc.go b/vendor/github.com/gorilla/mux/doc.go
index 013f08898..38957deea 100644
--- a/vendor/github.com/gorilla/mux/doc.go
+++ b/vendor/github.com/gorilla/mux/doc.go
@@ -239,8 +239,7 @@ as well:
"category", "technology",
"id", "42")
-Since **vX.Y.Z**, mux supports the addition of middlewares to a [Router](https://godoc.org/github.com/gorilla/mux#Router), which are executed if a
-match is found (including subrouters). Middlewares are defined using the de facto standard type:
+Mux supports the addition of middlewares to a Router, which are executed in the order they are added if a match is found, including its subrouters. Middlewares are (typically) small pieces of code which take one request, do something with it, and pass it down to another middleware or the final handler. Some common use cases for middleware are request logging, header manipulation, or ResponseWriter hijacking.
type MiddlewareFunc func(http.Handler) http.Handler
@@ -261,7 +260,7 @@ Middlewares can be added to a router using `Router.Use()`:
r := mux.NewRouter()
r.HandleFunc("/", handler)
- r.AddMiddleware(simpleMw)
+ r.Use(simpleMw)
A more complex authentication middleware, which maps session token to users, could be written as:
@@ -288,7 +287,7 @@ A more complex authentication middleware, which maps session token to users, cou
log.Printf("Authenticated user %s\n", user)
next.ServeHTTP(w, r)
} else {
- http.Error(w, "Forbidden", 403)
+ http.Error(w, "Forbidden", http.StatusForbidden)
}
})
}