luci: go.chromium.org/luci/server/middleware Index | Files

package middleware

import "go.chromium.org/luci/server/middleware"

Package middleware defines base type for context-aware HTTP request handler. See appengine/middleware for examples of how to use it in GAE environment.

Index

Package Files

middleware.go paniccatcher.go

func WithContextTimeout Uses

func WithContextTimeout(timeout time.Duration) router.Middleware

WithContextTimeout returns a middleware that adds a timeout to the context.

func WithPanicCatcher Uses

func WithPanicCatcher(c *router.Context, next router.Handler)

WithPanicCatcher is a middleware that catches panics, dumps stack trace to logging and returns HTTP 500.

type Base Uses

type Base func(Handler) httprouter.Handle

Base is a start of the middlware chain. It sets up initial context with all base services and passes it to the given handler. Return value of Base can be plugged in into httprouter directly.

func TestingBase Uses

func TestingBase(c context.Context) Base

TestingBase is Base that passes given context to the handler. Useful in tests.

type Handler Uses

type Handler func(context.Context, http.ResponseWriter, *http.Request, httprouter.Params)

Handler is the type for all request handlers. Of particular note, it's the same as httprouter.Handle, except that it also has a context parameter.

type Middleware Uses

type Middleware func(Handler) Handler

Middleware takes a handler, wraps it with some additional logic, and returns resulting handler.

Package middleware imports 8 packages (graph) and is imported by 4 packages. Updated 2018-10-21. Refresh now. Tools for package owners.