Documentation ¶
Index ¶
- Constants
- Variables
- func NewCookie(name string, value string, age ...int64) *http.Cookie
- func NewSecureCookie(secret, name string, val string, age ...int64) *http.Cookie
- func Version() string
- type AbortError
- type Compress
- type Compresser
- type Context
- func (ctx *Context) Abort(status int, body string)
- func (ctx *Context) Action() interface{}
- func (ctx *Context) Cookies() Cookies
- func (ctx *Context) Download(fpath string) error
- func (ctx *Context) HandleError()
- func (ctx *Context) Invoke()
- func (ctx *Context) Next()
- func (ctx *Context) NotFound(message ...string)
- func (ctx *Context) NotModified()
- func (ctx *Context) Params() url.Values
- func (ctx *Context) Redirect(url string, status ...int)
- func (ctx *Context) Req() *http.Request
- func (ctx *Context) Route() *Route
- func (ctx *Context) SecureCookies(secret string) Cookies
- func (ctx *Context) ServeFile(path string) error
- func (ctx *Context) ServeJson(obj interface{}) error
- func (ctx *Context) ServeXml(obj interface{}) error
- func (ctx *Context) Unauthorized()
- type Contexter
- type Cookies
- type Ctx
- type Deflate
- type GZip
- type Group
- func (g *Group) Any(url string, c interface{})
- func (g *Group) Delete(url string, c interface{})
- func (g *Group) Get(url string, c interface{})
- func (g *Group) Group(p string, o interface{})
- func (g *Group) Head(url string, c interface{})
- func (g *Group) Options(url string, c interface{})
- func (g *Group) Patch(url string, c interface{})
- func (g *Group) Post(url string, c interface{})
- func (g *Group) Put(url string, c interface{})
- func (g *Group) Route(methods []string, url string, c interface{})
- func (g *Group) Trace(url string, c interface{})
- func (g *Group) Use(handlers ...Handler)
- type Handler
- type HandlerFunc
- func Compresses(exts []string) HandlerFunc
- func Contexts() HandlerFunc
- func Errors() HandlerFunc
- func Logging() HandlerFunc
- func Param() HandlerFunc
- func Prefix(prefix string, handler Handler) HandlerFunc
- func Recovery(debug bool) HandlerFunc
- func Requests() HandlerFunc
- func Responses() HandlerFunc
- func Return() HandlerFunc
- func Static(opts ...StaticOptions) HandlerFunc
- func WrapAfter(handler http.Handler) HandlerFunc
- func WrapBefore(handler http.Handler) HandlerFunc
- type HttpResponser
- type Json
- type Log
- type LogInterface
- type Logger
- type Paramer
- type Params
- type PathType
- type Req
- type Requester
- type Resp
- type ResponseTyper
- type ResponseWriter
- type Responser
- type Route
- type RouteType
- type Router
- type StaticOptions
- type Tango
- func (t *Tango) Any(url string, c interface{})
- func (t *Tango) Delete(url string, c interface{})
- func (t *Tango) Get(url string, c interface{})
- func (t *Tango) Group(p string, o interface{})
- func (t *Tango) Head(url string, c interface{})
- func (t *Tango) Logger() Logger
- func (t *Tango) Options(url string, c interface{})
- func (t *Tango) Patch(url string, c interface{})
- func (t *Tango) Post(url string, c interface{})
- func (t *Tango) Put(url string, c interface{})
- func (t *Tango) Run(addrs ...string)
- func (t *Tango) RunTLS(certFile, keyFile string, addrs ...string)
- func (t *Tango) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (t *Tango) Trace(url string, c interface{})
- func (t *Tango) Use(handlers ...Handler)
- func (t *Tango) UseHandler(handler http.Handler)
- type Xml
- type XmlError
- type XmlString
Constants ¶
View Source
const ( HeaderAcceptEncoding = "Accept-Encoding" HeaderContentEncoding = "Content-Encoding" HeaderContentLength = "Content-Length" HeaderContentType = "Content-Type" HeaderVary = "Vary" )
View Source
const ( AutoResponse = iota JsonResponse XmlResponse )
View Source
const ( Dev = iota Prod )
Variables ¶
View Source
var ( SupportMethods = []string{ "GET", "POST", "HEAD", "DELETE", "PUT", "OPTIONS", "TRACE", "PATCH", } PoolSize = 800 )
View Source
var ( ClassicHandlers = []Handler{ Logging(), Recovery(true), Compresses([]string{".js", ".css", ".html", ".htm"}), Static(StaticOptions{Prefix: "public"}), Return(), Responses(), Requests(), Param(), Contexts(), } )
View Source
var (
Env = Dev
)
Functions ¶
func NewSecureCookie ¶
Types ¶
type AbortError ¶
func Abort ¶
func Abort(code int, content ...string) AbortError
func Forbidden ¶
func Forbidden(content ...string) AbortError
func InternalServerError ¶
func InternalServerError(content ...string) AbortError
func NotFound ¶
func NotFound(content ...string) AbortError
func NotSupported ¶
func NotSupported(content ...string) AbortError
func Unauthorized ¶
func Unauthorized(content ...string) AbortError
type Compresser ¶
type Compresser interface {
CompressType() string
}
type Context ¶
type Context struct { Logger ResponseWriter Result interface{} // contains filtered or unexported fields }
func NewContext ¶
func (*Context) Abort ¶
Abort is a helper method that sends an HTTP header and an optional body. It is useful for returning 4xx or 5xx errors. Once it has been called, any return value from the handler will not be written to the response.
func (*Context) HandleError ¶
func (ctx *Context) HandleError()
func (*Context) NotModified ¶
func (ctx *Context) NotModified()
Notmodified writes a 304 HTTP response
func (*Context) SecureCookies ¶
func (*Context) Unauthorized ¶
func (ctx *Context) Unauthorized()
type HandlerFunc ¶
type HandlerFunc func(ctx *Context)
func Compresses ¶
func Compresses(exts []string) HandlerFunc
func Contexts ¶
func Contexts() HandlerFunc
func Logging ¶
func Logging() HandlerFunc
func Param ¶
func Param() HandlerFunc
func Prefix ¶ added in v0.2.9
func Prefix(prefix string, handler Handler) HandlerFunc
func Recovery ¶
func Recovery(debug bool) HandlerFunc
func Requests ¶
func Requests() HandlerFunc
func Responses ¶
func Responses() HandlerFunc
func Return ¶
func Return() HandlerFunc
func Static ¶
func Static(opts ...StaticOptions) HandlerFunc
func WrapAfter ¶
func WrapAfter(handler http.Handler) HandlerFunc
func WrapBefore ¶
func WrapBefore(handler http.Handler) HandlerFunc
func (HandlerFunc) Handle ¶
func (h HandlerFunc) Handle(ctx *Context)
type HttpResponser ¶
type HttpResponser interface {
SetResponse(http.ResponseWriter)
}
type LogInterface ¶
type LogInterface interface {
SetLogger(Logger)
}
type Logger ¶
type Req ¶
func (*Req) SetRequest ¶
type Resp ¶
type Resp struct {
ResponseWriter
}
func (*Resp) SetResponse ¶
func (resp *Resp) SetResponse(r ResponseWriter)
type ResponseTyper ¶
type ResponseTyper interface {
ResponseType() int
}
type ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter http.Flusher // Status returns the status code of the response or 0 if the response has not been written. Status() int // Written returns whether or not the ResponseWriter has been written. Written() bool // Size returns the size of the response body. Size() int }
ResponseWriter is a wrapper around http.ResponseWriter that provides extra information about the response. It is recommended that middleware handlers use this construct to wrap a responsewriter if the functionality calls for it.
func NewResponseWriter ¶
func NewResponseWriter(rw http.ResponseWriter) ResponseWriter
NewResponseWriter creates a ResponseWriter that wraps an http.ResponseWriter
type Responser ¶
type Responser interface {
SetResponse(ResponseWriter)
}
type RouteType ¶
type RouteType int
const ( FuncRoute RouteType = iota + 1 // func () FuncHttpRoute // func (http.ResponseWriter, *http.Request) FuncReqRoute // func (*http.Request) FuncResponseRoute // func (http.ResponseWriter) FuncCtxRoute // func (*tango.Context) StructRoute // func (st) <Get>() StructPtrRoute // func (*struct) <Get>() )
type Router ¶
type StaticOptions ¶
Click to show internal directories.
Click to hide internal directories.