web

package
v0.0.0-...-bc6c5c1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Ok         = Response{Status: http.StatusOK}
	NotFound   = Response{Status: http.StatusNotFound}
	Forbidden  = Response{Status: http.StatusForbidden}
	BadRequest = Response{Status: http.StatusBadRequest}
)

Functions

func Wrap

Types

type Context

type Context interface {
	Response() http.ResponseWriter
	Request() *http.Request
	WithRequest(req *http.Request) Context
	RouteValue(name string) string
	RouteKey(name string) types.Key
	RouteID(name string) types.ID
	Query(name string) string
	FormValue(name string) string
	Set(k string, v interface{})
	Get(k string) interface{}
	JSON(status int, in interface{}) error
	XMLBlob(status int, in []byte) error
	Text(status int, in string) error
	HTML(status int, in string) error
	Redirect(status int, location string) error
}

type Filter

type Filter func(h HandlerFunc) HandlerFunc

func (Filter) Apply

func (f Filter) Apply(h HandlerFunc) HandlerFunc

type Filters

type Filters []Filter

func (Filters) Apply

func (f Filters) Apply(h HandlerFunc) HandlerFunc

type HandlerFunc

type HandlerFunc func(c Context) error

func WrapHandler

func WrapHandler(h http.Handler) HandlerFunc

type Response

type Response struct {
	Status  int    `json:"status"`
	Message string `json:"message,omitempty"`
}

type Router

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

func NewRouter

func NewRouter() *Router

func (*Router) Bind

func (r *Router) Bind(endpoints ...*swagger.Endpoint) error

func (*Router) DELETE

func (r *Router) DELETE(path string, h HandlerFunc)

func (*Router) GET

func (r *Router) GET(path string, h HandlerFunc)

func (*Router) Group

func (r *Router) Group(prefix string, filters ...Filter) *Router

func (*Router) HEAD

func (r *Router) HEAD(path string, h HandlerFunc)

func (*Router) Handle

func (r *Router) Handle(method, path string, h HandlerFunc)

func (*Router) OPTION

func (r *Router) OPTION(path string, h HandlerFunc)

func (*Router) POST

func (r *Router) POST(path string, h HandlerFunc)

func (*Router) PUT

func (r *Router) PUT(path string, h HandlerFunc)

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Router) Use

func (r *Router) Use(filters ...Filter)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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