middleware

package
v0.0.0-...-b76ab4a Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package middleware provides middleware components for the HTTP listener. This includes functions to handle logging HTTP requests, CORS access control, and OPTIONS requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppContext

type AppContext struct {
	DB  *sql.DB
	Log *logging.Logger
}

AppContext holds context data for the application. This can hold information such as a database connection, session data, user info, and more. Your middlewares should attach functions to this structure to pass critical data to request handlers.

func (*AppContext) AccessControl

func (ctx *AppContext) AccessControl(h http.Handler) http.Handler

AccessControl is a middleware that tells a browser abour CORS, allowed verbs, and accepted headers. Modify this to change these security features.

func (*AppContext) Authorization

func (ctx *AppContext) Authorization(h http.Handler) http.Handler

Authorization is a middleware for handling authorization of requests. Here is where you might authorize a token, user session, or cookie.

func (*AppContext) Logger

func (ctx *AppContext) Logger(h http.Handler) http.Handler

Logger is a middleware which logs requests to the console. It also includes the time it takes for the request to complete.

func (*AppContext) OptionsHandler

func (ctx *AppContext) OptionsHandler(h http.Handler) http.Handler

OptionsHandler is a middleware for handling OPTIONS requests.

func (*AppContext) StartAppContext

func (ctx *AppContext) StartAppContext(h http.Handler) http.Handler

StartAppContext is a middleware that should be early in the chain. This sets up the initial context and attaches important data to the Gorilla Context which comes across in the request.

Jump to

Keyboard shortcuts

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