mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
8d3467626e
This makes separating middlewares from the core api easier. As an example, the authorization middleware is moved to it's own package. Initialize all static middlewares when the server is created, reducing allocations every time a route is wrapper with the middlewares. Signed-off-by: David Calavera <david.calavera@gmail.com>
13 lines
485 B
Go
13 lines
485 B
Go
package middleware
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
// Middleware is an interface to allow the use of ordinary functions as Docker API filters.
|
|
// Any struct that has the appropriate signature can be registered as a middleware.
|
|
type Middleware interface {
|
|
WrapHandler(func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error) func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error
|
|
}
|