Documentation ¶
Index ¶
- Constants
- Variables
- func Dir(dir string) func(ctx *Context)
- func File(path string) func(ctx *Context)
- func GetAddress(args ...interface{}) string
- 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) Body() ([]byte, error)
- func (ctx *Context) Cookie(key string, defaults ...string) string
- func (ctx *Context) CookieBool(key string, defaults ...bool) bool
- func (ctx *Context) CookieEscape(key string, defaults ...string) string
- func (ctx *Context) CookieFloat32(key string, defaults ...float32) float32
- func (ctx *Context) CookieFloat64(key string, defaults ...float64) float64
- func (ctx *Context) CookieInt(key string, defaults ...int) int
- func (ctx *Context) CookieInt32(key string, defaults ...int32) int32
- func (ctx *Context) CookieInt64(key string, defaults ...int64) int64
- func (ctx *Context) CookieUint(key string, defaults ...uint) uint
- func (ctx *Context) CookieUint32(key string, defaults ...uint32) uint32
- func (ctx *Context) CookieUint64(key string, defaults ...uint64) uint64
- func (ctx *Context) Cookies() Cookies
- func (ctx *Context) DecodeJson(obj interface{}) error
- func (ctx *Context) DecodeXml(obj interface{}) error
- func (ctx *Context) Download(fpath string) error
- func (ctx *Context) Form(key string, defaults ...string) string
- func (ctx *Context) FormBool(key string, defaults ...bool) bool
- func (ctx *Context) FormEscape(key string, defaults ...string) string
- func (ctx *Context) FormFloat32(key string, defaults ...float32) float32
- func (ctx *Context) FormFloat64(key string, defaults ...float64) float64
- func (ctx *Context) FormInt(key string, defaults ...int) int
- func (ctx *Context) FormInt32(key string, defaults ...int32) int32
- func (ctx *Context) FormInt64(key string, defaults ...int64) int64
- func (ctx *Context) FormStrings(key string, defaults ...[]string) []string
- func (ctx *Context) FormUint(key string, defaults ...uint) uint
- func (ctx *Context) FormUint32(key string, defaults ...uint32) uint32
- func (ctx *Context) FormUint64(key string, defaults ...uint64) uint64
- func (ctx *Context) Forms() *Forms
- func (ctx *Context) HandleError()
- func (ctx *Context) IP() string
- func (ctx *Context) IsAjax() bool
- func (ctx *Context) Next()
- func (ctx *Context) NotFound(message ...string)
- func (ctx *Context) NotModified()
- func (ctx *Context) Param(key string, defaults ...string) string
- func (ctx *Context) ParamBool(key string, defaults ...bool) bool
- func (ctx *Context) ParamEscape(key string, defaults ...string) string
- func (ctx *Context) ParamFloat32(key string, defaults ...float32) float32
- func (ctx *Context) ParamFloat64(key string, defaults ...float64) float64
- func (ctx *Context) ParamInt(key string, defaults ...int) int
- func (ctx *Context) ParamInt32(key string, defaults ...int32) int32
- func (ctx *Context) ParamInt64(key string, defaults ...int64) int64
- func (ctx *Context) ParamStrings(key string, defaults ...[]string) []string
- func (ctx *Context) ParamUint(key string, defaults ...uint) uint
- func (ctx *Context) ParamUint32(key string, defaults ...uint32) uint32
- func (ctx *Context) ParamUint64(key string, defaults ...uint64) uint64
- 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) Escape(key string) (string, 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, defaults ...bool) bool
- func (f *Forms) MustEscape(key string, defaults ...string) string
- func (f *Forms) MustFloat32(key string, defaults ...float32) float32
- func (f *Forms) MustFloat64(key string, defaults ...float64) float64
- func (f *Forms) MustInt(key string, defaults ...int) int
- func (f *Forms) MustInt32(key string, defaults ...int32) int32
- func (f *Forms) MustInt64(key string, defaults ...int64) int64
- func (f *Forms) MustString(key string, defaults ...string) string
- func (f *Forms) MustStrings(key string, defaults ...[]string) []string
- func (f *Forms) MustUint(key string, defaults ...uint) uint
- func (f *Forms) MustUint32(key string, defaults ...uint32) uint32
- func (f *Forms) MustUint64(key string, defaults ...uint64) uint64
- func (f *Forms) String(key string) (string, error)
- func (f *Forms) Strings(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)
- func (f *Forms) Values() url.Values
- 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 interface{}, url string, c interface{}, handlers ...Handler)
- 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) Escape(key string) (string, 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, defaults ...bool) bool
- func (p *Params) MustEscape(key string, defaults ...string) string
- func (p *Params) MustFloat32(key string, defaults ...float32) float32
- func (p *Params) MustFloat64(key string, defaults ...float64) float64
- func (p *Params) MustInt(key string, defaults ...int) int
- func (p *Params) MustInt32(key string, defaults ...int32) int32
- func (p *Params) MustInt64(key string, defaults ...int64) int64
- func (p *Params) MustString(key string, defaults ...string) string
- func (p *Params) MustStrings(key string, defaults ...[]string) []string
- func (p *Params) MustUint(key string, defaults ...uint) uint
- func (p *Params) MustUint32(key string, defaults ...uint32) uint32
- func (p *Params) MustUint64(key string, defaults ...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) Strings(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 StatusResult
- 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 = 10 )
View Source
var ( ClassicHandlers = []Handler{ Logging(), Recovery(false), Compresses([]string{}), Static(StaticOptions{Prefix: "public"}), Return(), Param(), Contexts(), } )
Functions ¶
func GetAddress ¶ added in v0.4.6
func GetAddress(args ...interface{}) string
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) CookieBool ¶ added in v0.5.0
func (*Context) CookieEscape ¶ added in v0.5.0
func (*Context) CookieFloat32 ¶ added in v0.5.0
func (*Context) CookieFloat64 ¶ added in v0.5.0
func (*Context) CookieInt32 ¶ added in v0.5.0
func (*Context) CookieInt64 ¶ added in v0.5.0
func (*Context) CookieUint ¶ added in v0.5.0
func (*Context) CookieUint32 ¶ added in v0.5.0
func (*Context) CookieUint64 ¶ added in v0.5.0
func (*Context) DecodeJson ¶ added in v0.5.0
func (*Context) FormEscape ¶ added in v0.5.0
func (*Context) FormFloat32 ¶ added in v0.5.0
func (*Context) FormFloat64 ¶ added in v0.5.0
func (*Context) FormStrings ¶ added in v0.5.0
func (*Context) FormUint32 ¶ added in v0.5.0
func (*Context) FormUint64 ¶ added in v0.5.0
func (*Context) HandleError ¶
func (ctx *Context) HandleError()
func (*Context) NotModified ¶
func (ctx *Context) NotModified()
Notmodified writes a 304 HTTP response
func (*Context) ParamEscape ¶ added in v0.5.0
func (*Context) ParamFloat32 ¶ added in v0.5.0
func (*Context) ParamFloat64 ¶ added in v0.5.0
func (*Context) ParamInt32 ¶ added in v0.5.0
func (*Context) ParamInt64 ¶ added in v0.5.0
func (*Context) ParamStrings ¶ added in v0.5.0
func (*Context) ParamUint32 ¶ added in v0.5.0
func (*Context) ParamUint64 ¶ added in v0.5.0
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
Forms a new enhancement of http.Request
func (*Forms) MustEscape ¶ added in v0.5.0
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) MustStrings ¶ added in v0.5.0
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) MustEscape ¶ added in v0.5.0
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) MustStrings ¶ added in v0.5.0
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, defaults ...string) string MustEscape(key string, defaults ...string) string MustInt(key string, defaults ...int) int MustInt32(key string, defaults ...int32) int32 MustInt64(key string, defaults ...int64) int64 MustUint(key string, defaults ...uint) uint MustUint32(key string, defaults ...uint32) uint32 MustUint64(key string, defaults ...uint64) uint64 MustFloat32(key string, defaults ...float32) float32 MustFloat64(key string, defaults ...float64) float64 MustBool(key string, defaults ...bool) bool }
type StaticOptions ¶
type StatusResult ¶ added in v0.5.0
type StatusResult struct { Code int Result interface{} }
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.