2018-07-07 20:10:56 +00:00
|
|
|
package middleware
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Scope represents a list of scope processed by middlewares
|
|
|
|
// and used by the router to block/allow some uris
|
|
|
|
// it is also passed to controllers
|
|
|
|
type Scope []string
|
|
|
|
|
|
|
|
// Inspector updates the @Scope passed to it according to
|
|
|
|
// the @http.Request
|
2018-07-07 21:15:42 +00:00
|
|
|
type Inspector func(http.Request, *Scope)
|
2018-07-07 20:10:56 +00:00
|
|
|
|
2018-07-08 23:34:21 +00:00
|
|
|
// MiddleWare contains all necessary methods
|
2018-07-07 20:10:56 +00:00
|
|
|
// for a Middleware provided by user/developer
|
|
|
|
type MiddleWare struct {
|
2018-07-07 21:15:42 +00:00
|
|
|
Inspect func(http.Request, *Scope)
|
2018-07-07 20:10:56 +00:00
|
|
|
}
|
|
|
|
|
2018-07-08 23:34:21 +00:00
|
|
|
// Registry represents a registry containing all registered
|
2018-07-07 20:10:56 +00:00
|
|
|
// middlewares to be processed before routing any request
|
2018-07-08 23:34:21 +00:00
|
|
|
type Registry struct {
|
2018-07-07 20:10:56 +00:00
|
|
|
Middlewares []MiddleWare
|
|
|
|
}
|