middleware

package
v0.0.0-...-d9c4052 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2014 License: GPL-3.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateContext

CreateContext initializes the context for a request

func LoginForbidden

func LoginForbidden(c Context)

LoginForbidden returns an error if the user is logged in

func LoginRequired

func LoginRequired(c Context)

LoginRequired returns an error if the user is not logged in

func RequiresValidSignature

func RequiresValidSignature(c Context)

RequiresValidSignature returns an error if the request signature is not valid

func WebOnly

func WebOnly(c Context)

WebOnly returns an error if the user token is not a session token

Types

type Context

type Context struct {
	Config         *services.Config
	Conn           *services.Connection
	Request        *http.Request
	Render         render.Render
	Session        *sessions.Session
	User           *models.User
	Tasks          *services.TaskService
	ResponseWriter http.ResponseWriter
	IsWebToken     bool
}

func (Context) AsyncQuery

func (c Context) AsyncQuery(fn func(*services.Connection))

func (Context) Count

func (c Context) Count(colName string, query interface{}) (int, error)

func (Context) Error

func (c Context) Error(status, code int, message string)

Error renders a single error message

func (Context) Errors

func (c Context) Errors(status int, codes []int, messages []string)

Errors renders a json response with an array of errors

func (Context) Find

func (c Context) Find(colName string, where interface{}) *mgo.Query

func (Context) FindId

func (c Context) FindId(colName string, id interface{}) *mgo.Query

func (Context) Form

func (c Context) Form(name string) string

Form returns the value at the given form key

func (Context) GetBoolean

func (c Context) GetBoolean(key string) bool

func (Context) ListCountParams

func (c Context) ListCountParams() (int, int)

ListCountParams returns the count and offset parameters from the request

func (Context) Query

func (c Context) Query(colName string) *mgo.Collection

Query returns a pointer to a collection

func (Context) Remove

func (c Context) Remove(colName string, selector interface{}) error

func (Context) RemoveAll

func (c Context) RemoveAll(colName string, selector interface{}) (*mgo.ChangeInfo, error)

func (Context) RequestIsValid

func (c Context) RequestIsValid(isAccessKey bool) bool

RequestIsValid returns if the current request signature is valid and thus is a valid request

func (Context) Success

func (c Context) Success(status int, data map[string]interface{})

Success renders a successful JSON response

Jump to

Keyboard shortcuts

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