middleware

package
v0.0.0-...-370a347 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2015 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateId

func GenerateId() string

func NewMongoDb

func NewMongoDb(path string) *mongoDBContext

func NewSession

func NewSession() *sessionMemoryMW

func NewSessionId

func NewSessionId() *sessionIdContext

NewSessionId Creates a SessionId and keeps track of the session using cookies This Middleware only manages a sessionid and does manage session data.

func NewSessionMongoDB

func NewSessionMongoDB() *sessionMongoDBMW

func NewUserCustomStoreMW

func NewUserCustomStoreMW(storefactory func(*webapp.Context) UserStore) *userMW

NewUserCustomStoreMW Allows a custom store constructor. The storefactory method must return a struct of type UserStore Interface

func NewUserMW

func NewUserMW() *userMW

NewUserMW Create a User Authentication Middleware with mongodb as default user store.

Types

type BasicSession

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

BasicSession is a basic session store that stores session data in local memory

func (*BasicSession) Get

func (this *BasicSession) Get(name string) interface{}

Get get a session variable

func (*BasicSession) GetAll

func (this *BasicSession) GetAll() map[string]interface{}

GetAll Get all session variables.

func (*BasicSession) SessionId

func (this *BasicSession) SessionId() string

SessionId return the sessionid associated with this session.

func (*BasicSession) Set

func (this *BasicSession) Set(name string, value interface{}) webapp.Session

Set a session variable if value is nil, the key will be removed from the Session.

func (*BasicSession) SetSessionId

func (this *BasicSession) SetSessionId(id string)

type DefaultUserStore

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

func (*DefaultUserStore) Authenticate

func (this *DefaultUserStore) Authenticate(username, password string) bool

func (*DefaultUserStore) GetUser

func (this *DefaultUserStore) GetUser(username string) *webapp.User

func (*DefaultUserStore) VerifyUser

func (this *DefaultUserStore) VerifyUser(username string) bool

type M

type M map[string]interface{}

type SessionMongoDB

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

SessionMongoDB store session data in mangodb

func (*SessionMongoDB) Get

func (this *SessionMongoDB) Get(name string) interface{}

Get get a session variable

func (*SessionMongoDB) GetAll

func (this *SessionMongoDB) GetAll() map[string]interface{}

GetAll Get all session variables.

func (*SessionMongoDB) SessionId

func (this *SessionMongoDB) SessionId() string

SessionId return the sessionid associated with this session.

func (*SessionMongoDB) Set

func (this *SessionMongoDB) Set(name string, value interface{}) webapp.Session

Set a session variable if value is nil, the key will be removed from the Session.

func (*SessionMongoDB) SetSessionId

func (this *SessionMongoDB) SetSessionId(id string)

type Static

type Static struct {
	// Dir is the directory to serve static files from
	Dir http.FileSystem
	// Prefix is the optional prefix used to serve the static directory content
	Prefix string
	// IndexFile defines which file to serve as index if it exists.
	IndexFile string
}

Static is a middleware handler that serves static files in the given directory/filesystem.

func NewStatic

func NewStatic(directory http.FileSystem) *Static

NewStatic returns a new instance of Static

func (*Static) ServeHTTP

func (s *Static) ServeHTTP(c *webapp.Context, next webapp.HandlerFunc)

type UserStore

type UserStore interface {
	VerifyUser(username string) bool
	Authenticate(username, password string) bool
	GetUser(username string) *webapp.User
}

UserStore allows for customizing user stores

Jump to

Keyboard shortcuts

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