ctx

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Params         httprouter.Params
	BeatmapService cheesegull.BeatmapService
	FileResolver   cheesegull.FileResolver
	Communication  cheesegull.CommunicationService
	ErrorHandler   func(error)
	Request        *http.Request
}

Context is the information about the request passed to an handler in the http package, alongside http.ResponseWriter and *http.Request.

func (*Context) HandleError

func (r *Context) HandleError(err error)

HandleError handles an error, passing it to ErrorHandler or printing it and printing the stacktrace.

func (*Context) Param

func (r *Context) Param(s string) string

Param retrieves a parameters from the parameters in the Context

func (*Context) QueryDefault added in v1.0.0

func (r *Context) QueryDefault(q string, def string) string

QueryDefault returns a value from the query string. If it's not set, the default value provided is used.

func (*Context) QueryInt added in v1.0.0

func (r *Context) QueryInt(q string) int

QueryInt gets an integer value from the querystring. Returns 0 if it's not a valid int.

func (*Context) QueryIntDefault added in v1.0.0

func (r *Context) QueryIntDefault(q string, i int) int

QueryIntDefault gets an integer value from the querystring, or if the requested parameter is not in the querystring, then it returns a default value.

func (*Context) QueryIntMultiple added in v1.0.0

func (r *Context) QueryIntMultiple(q string) []int

QueryIntMultiple is basically like QueryInt, but returns an []int with all the ints with the same key passed.

Jump to

Keyboard shortcuts

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