webapp

package
v0.0.0-...-5efa5bd Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2017 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(mux *mux.Router, stopKeyReset chan struct{}) (err error)

Register appends webapp handlers to the mux.Router

Types

type Context

type Context struct {
	Request  *http.Request
	Response http.ResponseWriter
	T        *template.Template
	Status   int

	Data webData
}

Context is the context object shared between http handlers

func (*Context) Admin

func (c *Context) Admin() bool

Admin returns the users admin privileges

func (*Context) Auth

func (c *Context) Auth() (auth string)

Auth returns the users last auth method

func (*Context) CheckToken

func (c *Context) CheckToken() bool

CheckToken validates the xsrf token

func (*Context) Exec

func (c *Context) Exec()

Exec executes the configured http template

func (*Context) Form

func (c *Context) Form(name string) string

Form returns the given form value

func (*Context) FormSlice

func (c *Context) FormSlice(name string) []string

FormSlice returns a slice of form values

func (*Context) Group

func (c *Context) Group() (group string)

Group returns the last selected group

func (*Context) InitToken

func (c *Context) InitToken()

InitToken initializes a new xsrf token

func (*Context) JWT

func (c *Context) JWT() string

JWT returns the users JWT

func (*Context) LoggedOn

func (c *Context) LoggedOn() (ok bool)

LoggedOn checks if the user session is logged on

func (*Context) Method

func (c *Context) Method() string

Method returns the http method

func (*Context) Path

func (c *Context) Path() string

Path returns the uri path

func (*Context) Redirect

func (c *Context) Redirect(uri string, code int)

Redirect redirects to the given uri

func (*Context) SetData

func (c *Context) SetData(user, jwt, auth string, admin bool)

SetData sets the user sessions data

func (*Context) SetGroup

func (c *Context) SetGroup(group string)

SetGroup sets the last selected group

func (*Context) SetHeader

func (c *Context) SetHeader(name, value string)

SetHeader sets the given http header

func (*Context) Template

func (c *Context) Template(name string)

Template sets the given html template

func (*Context) UnsetData

func (c *Context) UnsetData()

UnsetData deletes the user session

func (*Context) User

func (c *Context) User() string

User returns the username

func (*Context) Var

func (c *Context) Var(name string) (ret string)

Var returns the given url variable

func (*Context) Write

func (c *Context) Write(buf []byte) (err error)

Write writes a slice of bytes as response

Jump to

Keyboard shortcuts

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