aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/gorilla/mux/middleware.go
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net> 2018-04-27 20:38:46 -0700
committerGravatar Frédéric Guillot <fred@miniflux.net> 2018-04-27 20:38:46 -0700
commit6b360d08c1f6c8a6cd1b7608f7af734a3ceef8d7 (patch)
tree48352d35fa9f3559df05accf4ce4fce1672a2830 /vendor/github.com/gorilla/mux/middleware.go
parent322b265d7aec7731f7fa703c9a74ceb61ae73f3f (diff)
downloadv2-6b360d08c1f6c8a6cd1b7608f7af734a3ceef8d7.tar.gz
v2-6b360d08c1f6c8a6cd1b7608f7af734a3ceef8d7.tar.zst
v2-6b360d08c1f6c8a6cd1b7608f7af734a3ceef8d7.zip
Use Gorilla middleware (refactoring)
Diffstat (limited to 'vendor/github.com/gorilla/mux/middleware.go')
-rw-r--r--vendor/github.com/gorilla/mux/middleware.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/github.com/gorilla/mux/middleware.go b/vendor/github.com/gorilla/mux/middleware.go
new file mode 100644
index 00000000..8f898675
--- /dev/null
+++ b/vendor/github.com/gorilla/mux/middleware.go
@@ -0,0 +1,28 @@
+package mux
+
+import "net/http"
+
+// MiddlewareFunc is a function which receives an http.Handler and returns another http.Handler.
+// Typically, the returned handler is a closure which does something with the http.ResponseWriter and http.Request passed
+// to it, and then calls the handler passed as parameter to the MiddlewareFunc.
+type MiddlewareFunc func(http.Handler) http.Handler
+
+// middleware interface is anything which implements a MiddlewareFunc named Middleware.
+type middleware interface {
+ Middleware(handler http.Handler) http.Handler
+}
+
+// MiddlewareFunc also implements the middleware interface.
+func (mw MiddlewareFunc) Middleware(handler http.Handler) http.Handler {
+ return mw(handler)
+}
+
+// Use appends a MiddlewareFunc to the chain. Middleware can be used to intercept or otherwise modify requests and/or responses, and are executed in the order that they are applied to the Router.
+func (r *Router) Use(mwf MiddlewareFunc) {
+ r.middlewares = append(r.middlewares, mwf)
+}
+
+// useInterface appends a middleware to the chain. Middleware can be used to intercept or otherwise modify requests and/or responses, and are executed in the order that they are applied to the Router.
+func (r *Router) useInterface(mw middleware) {
+ r.middlewares = append(r.middlewares, mw)
+}