This commit is contained in:
Adrien Marquès 2018-07-07 23:15:42 +02:00
parent 1afe04e13f
commit da38582add
2 changed files with 4 additions and 4 deletions

View File

@ -81,7 +81,7 @@ func (tr *MiddlewareRegistry) Add(pluginName string) error {
} }
/* (6) Cast Inspect */ /* (6) Cast Inspect */
inspectCast, ok := inspect.(func(http.Request, Scope)) inspectCast, ok := inspect.(func(http.Request, *Scope))
if !ok { if !ok {
return fmt.Errorf("Inspect() is malformed") return fmt.Errorf("Inspect() is malformed")
} }
@ -102,7 +102,7 @@ func (mr MiddlewareRegistry) Run(req http.Request) Scope {
/* (2) Execute each middleware */ /* (2) Execute each middleware */
for _, m := range mr.Middlewares { for _, m := range mr.Middlewares {
m.Inspect(req, scope) m.Inspect(req, &scope)
} }
return scope return scope

View File

@ -11,12 +11,12 @@ type Scope []string
// Inspector updates the @Scope passed to it according to // Inspector updates the @Scope passed to it according to
// the @http.Request // the @http.Request
type Inspector func(http.Request, Scope) type Inspector func(http.Request, *Scope)
// Middleware contains all necessary methods // Middleware contains all necessary methods
// for a Middleware provided by user/developer // for a Middleware provided by user/developer
type MiddleWare struct { type MiddleWare struct {
Inspect func(http.Request, Scope) Inspect func(http.Request, *Scope)
} }
// MiddlewareRegistry represents a registry containing all registered // MiddlewareRegistry represents a registry containing all registered