api

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: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(mux *mux.Router)

Register appends api handlers to the mux.Router

Types

type Context

type Context struct {
	User   string
	Admin  bool
	Body   []byte
	JWT    *jwt.Token
	Status int

	Request  *http.Request
	Response http.ResponseWriter
}

Context is the context object shared between http handlers

func (*Context) Err

func (c *Context) Err(err Error)

Err is a HTTPErr wrapper for the custom Error type

func (*Context) GetHeader

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

GetHeader returns the given http header

func (*Context) HTTPErr

func (c *Context) HTTPErr(err string, status int)

HTTPErr is a http.Error wrapper

func (*Context) JSON

func (c *Context) JSON(v interface{})

JSON is a json response

func (*Context) Method

func (c *Context) Method() string

Method returns the request method

func (*Context) OK

func (c *Context) OK()

OK is a empty HTTP 200 JSON response

func (*Context) SetHeader

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

SetHeader sets the given http header

func (*Context) Var

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

Var returns the given url variable

type Err

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

Err implements the Error interface

func (Err) Error

func (a Err) Error() string

Error returns the error string

func (Err) Status

func (a Err) Status() int

Status returns the HTTP status code

type Error

type Error interface {
	Error() string
	Status() int
}

Error interface is a custom api error

Jump to

Keyboard shortcuts

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