Documentation ¶
Index ¶
- Constants
- Variables
- func Dir(dir string) func(ctx *Context)
- func File(path string) func(ctx *Context)
- func GetAddress(args ...interface{}) string
- func GetDefaultListenInfo() (string, int)
- func NewCookie(name string, value string, age ...int64) *http.Cookie
- func NewRouter() (r *router)
- 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) Forms() *Forms
- 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() *Params
- func (ctx *Context) Redirect(url string, status ...int)
- func (ctx *Context) Req() *http.Request
- func (ctx *Context) Route() *Route
- func (ctx *Context) SaveToFile(formName, savePath string) error
- 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 Forms
- func (f *Forms) Bool(key string) (bool, error)
- func (f *Forms) Float32(key string) (float32, error)
- func (f *Forms) Float64(key string) (float64, error)
- func (f *Forms) Int(key string) (int, error)
- func (f *Forms) Int32(key string) (int32, error)
- func (f *Forms) Int64(key string) (int64, error)
- func (f *Forms) MustBool(key string, defs ...bool) bool
- func (f *Forms) MustFloat32(key string, defs ...float32) float32
- func (f *Forms) MustFloat64(key string, defs ...float64) float64
- func (f *Forms) MustInt(key string, defs ...int) int
- func (f *Forms) MustInt32(key string, defs ...int32) int32
- func (f *Forms) MustInt64(key string, defs ...int64) int64
- func (f *Forms) MustString(key string, defs ...string) string
- func (f *Forms) MustUint(key string, defs ...uint) uint
- func (f *Forms) MustUint32(key string, defs ...uint32) uint32
- func (f *Forms) MustUint64(key string, defs ...uint64) uint64
- func (f *Forms) String(key string) (string, error)
- func (f *Forms) Uint(key string) (uint, error)
- func (f *Forms) Uint32(key string) (uint32, error)
- func (f *Forms) Uint64(key string) (uint64, error)
- 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 Return() HandlerFunc
- func Static(opts ...StaticOptions) HandlerFunc
- func WrapAfter(handler http.Handler) HandlerFunc
- func WrapBefore(handler http.Handler) HandlerFunc
- type Json
- type Log
- type LogInterface
- type Logger
- type Paramer
- type Params
- func (p *Params) Bool(key string) (bool, error)
- func (p *Params) Float32(key string) (float32, error)
- func (p *Params) Float64(key string) (float64, error)
- func (p *Params) Get(key string) string
- func (p *Params) Int(key string) (int, error)
- func (p *Params) Int32(key string) (int32, error)
- func (p *Params) Int64(key string) (int64, error)
- func (p *Params) MustBool(key string, defs ...bool) bool
- func (p *Params) MustFloat32(key string, defs ...float32) float32
- func (p *Params) MustFloat64(key string, defs ...float64) float64
- func (p *Params) MustInt(key string, defs ...int) int
- func (p *Params) MustInt32(key string, defs ...int32) int32
- func (p *Params) MustInt64(key string, defs ...int64) int64
- func (p *Params) MustString(key string, defs ...string) string
- func (p *Params) MustUint(key string, defs ...uint) uint
- func (p *Params) MustUint32(key string, defs ...uint32) uint32
- func (p *Params) MustUint64(key string, defs ...uint64) uint64
- func (p *Params) Set(key, value string)
- func (p *Params) SetParams(params []param)
- func (p *Params) String(key string) (string, error)
- func (p *Params) Uint(key string) (uint, error)
- func (p *Params) Uint32(key string) (uint32, error)
- func (p *Params) Uint64(key string) (uint64, error)
- type ResponseTyper
- type ResponseWriter
- type Route
- type RouteType
- type Router
- type Set
- 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(args ...interface{})
- func (t *Tango) RunTLS(certFile, keyFile string, args ...interface{})
- 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 )
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{}), Static(StaticOptions{Prefix: "public"}), Return(), Param(), Contexts(), } )
Functions ¶
func GetAddress ¶ added in v0.4.6
func GetAddress(args ...interface{}) string
func GetDefaultListenInfo ¶ added in v0.4.6
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 (*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) SaveToFile ¶ added in v0.4.3
func (*Context) SecureCookies ¶
func (*Context) Unauthorized ¶
func (ctx *Context) Unauthorized()
type Forms ¶ added in v0.4.6
func (*Forms) MustFloat32 ¶ added in v0.4.6
func (*Forms) MustFloat64 ¶ added in v0.4.6
func (*Forms) MustString ¶ added in v0.4.6
func (*Forms) MustUint32 ¶ added in v0.4.6
func (*Forms) MustUint64 ¶ added in v0.4.6
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
TODO: regex prefix
func Recovery ¶
func Recovery(debug bool) 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 LogInterface ¶
type LogInterface interface {
SetLogger(Logger)
}
type Logger ¶
type Params ¶
type Params []param
func (*Params) MustFloat32 ¶ added in v0.4.6
func (*Params) MustFloat64 ¶ added in v0.4.6
func (*Params) MustString ¶ added in v0.4.6
func (*Params) MustUint32 ¶ added in v0.4.6
func (*Params) MustUint64 ¶ added in v0.4.6
type ResponseTyper ¶
type ResponseTyper interface {
ResponseType() int
}
type ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter http.Flusher http.Hijacker // 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.
type RouteType ¶
type RouteType byte
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 Set ¶ added in v0.4.6
type Set interface { String(key string) (string, error) Int(key string) (int, error) Int32(key string) (int32, error) Int64(key string) (int64, error) Uint(key string) (uint, error) Uint32(key string) (uint32, error) Uint64(key string) (uint64, error) Float32(key string) (float32, error) Float64(key string) (float64, error) Bool(key string) (bool, error) MustString(key string, defs ...string) string MustInt(key string, defs ...int) int MustInt32(key string, defs ...int32) int32 MustInt64(key string, defs ...int64) int64 MustUint(key string, defs ...uint) uint MustUint32(key string, defs ...uint32) uint32 MustUint64(key string, defs ...uint64) uint64 MustFloat32(key string, defs ...float32) float32 MustFloat64(key string, defs ...float64) float64 MustBool(key string, defs ...bool) bool }
type StaticOptions ¶
type Tango ¶
func NewWithLog ¶
func (*Tango) Run ¶
func (t *Tango) Run(args ...interface{})
Run the http server. Listening on os.GetEnv("PORT") or 8000 by default.
func (*Tango) UseHandler ¶
Click to show internal directories.
Click to hide internal directories.