middleware

package
v0.0.0-...-678bb0e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithPanicCatcher

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

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

Types

type Base

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

func TestingBase(c context.Context) Base

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

type Handler

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.

func WithContextValue

func WithContextValue(h Handler, key, val interface{}) Handler

WithContextValue is a middleware that adds a value to the context before calling the handler.

type Middleware

type Middleware func(Handler) Handler

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL