ctx

package module
v0.0.0-...-557c0b2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2016 License: MIT Imports: 11 Imported by: 10

README

ctx

Go (golang) Web Context

Warning: This package is a work in progress and the APIs are subject to change. Consider this a v0 project.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(rw http.ResponseWriter, message string, args ...interface{}) error

func Created

func Created(rw http.ResponseWriter, response interface{}) error

func Errorf

func Errorf(rw http.ResponseWriter, statusCode int, message string, args ...interface{}) error

func Init

func Init(router *mux.Router, privKey, pubKey string, vars map[string]interface{}) error

func InternalServerError

func InternalServerError(rw http.ResponseWriter, message string, args ...interface{}) error

func LoadSecureKeys

func LoadSecureKeys(privateKeyPath, publicKeyPath string) (err error)

func NoContent

func NoContent(rw http.ResponseWriter) error

func NotFound

func NotFound(rw http.ResponseWriter, message string, args ...interface{}) error

func OK

func OK(rw http.ResponseWriter, response interface{}) error

func Register

func Register(endpoint *Endpoint)

func Resource

func Resource(path string, res interface{}, public bool)

func SignToken

func SignToken(token *jwt.Token) (string, error)

func Success

func Success(rw http.ResponseWriter, statusCode int, response interface{}) error

Types

type Context

type Context struct {
	Router *mux.Router
	Vars   map[string]interface{}

	T i18n.TranslateFunc

	Token *jwt.Token
	// contains filtered or unexported fields
}

type ContextHandler

type ContextHandler func(c *Context, rw http.ResponseWriter, req *http.Request) error

type Deleter

type Deleter interface {
	DELETE(c *Context, rw http.ResponseWriter, req *http.Request) error
}

type Endpoint

type Endpoint struct {
	Public   bool
	Path     string
	Handlers map[string]ContextHandler
}

type Getter

type Getter interface {
	GET(c *Context, rw http.ResponseWriter, req *http.Request) error
}

type Poster

type Poster interface {
	POST(c *Context, rw http.ResponseWriter, req *http.Request) error
}

type Putter

type Putter interface {
	PUT(c *Context, rw http.ResponseWriter, req *http.Request) error
}

Jump to

Keyboard shortcuts

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