users

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2017 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handle

type Handle func(rw http.ResponseWriter, req *http.Request, par httprouter.Params) error

Handle is similar to httprouter.Handle, except it returns an error which can be handled separately.

type Module

type Module struct {
	Auth     *users.Module
	Sessions *session.Module
	Config   *config.Module
	Router   *router.Module
	DB       *db.Module
	Logger   *logger.Module

	// todo: make these pluggable?
	DBAuth    *databaseauth.Module
	TokenAuth *tokenauth.Module
}

Module users is a largely a wrapper around nagax/users/databaseauth to enable user logins.

func (*Module) ErrorHandler

func (m *Module) ErrorHandler(rw http.ResponseWriter, req *http.Request, err error)

ErrorHandler to handle auth errors. todo: return more fine-grained error codes.

func (*Module) Init

func (m *Module) Init(c *service.Config)

Init implements service.Init

func (*Module) MustWithAuth

func (m *Module) MustWithAuth(delegate Handle) Handle

MustWithAuth wraps a Handle function and requires a logged in user. The new handler will authenticate using the auth module, creating another wrapper for the original function to make it compatible with http.HandlerFunc (while ensuring it closes over httprouter.Params).

Jump to

Keyboard shortcuts

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