handlers

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2014 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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)
	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