handlers

package
v0.9.1-0...-e335e2d Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2015 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Unauthorized http.HandlerFunc = unauthorized

Functions

func NewRequestAuthenticator

func NewRequestAuthenticator(context RequestContext, auth authenticator.Request, failed http.Handler, handler http.Handler) http.Handler

NewRequestAuthenticator creates an http handler that tries to authenticate the given request as a user, and then stores any such user found onto the provided context for the request. If authentication fails or returns an error the failed handler is used. On success, handler is invoked to serve the request.

Types

type RequestContext

type RequestContext interface {
	Set(*http.Request, user.Info)
	Get(req *http.Request) (user.Info, bool)
	Remove(*http.Request)
}

RequestContext is the interface used to associate a user with an http Request.

type UserRequestContext

type UserRequestContext struct {
	// contains filtered or unexported fields
}

UserRequestContext allows different levels of a call stack to store/retrieve info about the current user associated with an http.Request.

func NewUserRequestContext

func NewUserRequestContext() *UserRequestContext

NewUserRequestContext provides a map for storing and retrieving users associated with requests. Be sure to pair each `context.Set(req, user)` call with a `defer context.Remove(req)` call or you will leak requests. It implements the RequestContext interface.

func (*UserRequestContext) Get

func (c *UserRequestContext) Get(req *http.Request) (user.Info, bool)

func (*UserRequestContext) Remove

func (c *UserRequestContext) Remove(req *http.Request)

func (*UserRequestContext) Set

func (c *UserRequestContext) Set(req *http.Request, user user.Info)

Jump to

Keyboard shortcuts

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