mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
More middleware updates.
This commit is contained in:
@@ -21,7 +21,6 @@ func main() {
|
||||
funcServer.AddMiddlewareFunc(func(ctx server.MiddlewareContext, w http.ResponseWriter, r *http.Request, app *models.App) error {
|
||||
start := time.Now()
|
||||
fmt.Println("CustomMiddlewareFunc called at:", start)
|
||||
// TODO: probably need a way to let the chain go forward here and return back to the middleware, for things like timing, etc.
|
||||
ctx.Next()
|
||||
fmt.Println("Duration:", (time.Now().Sub(start)))
|
||||
return nil
|
||||
@@ -48,5 +47,6 @@ func (h *CustomMiddleware) Serve(ctx server.MiddlewareContext, w http.ResponseWr
|
||||
return errors.New("Invalid authorization token.")
|
||||
}
|
||||
fmt.Println("auth succeeded!")
|
||||
ctx.Set("user", "I'm in!")
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user