Documentation ¶
Index ¶
- Constants
- Variables
- func Dir(dir string) func(ctx *Context)
- func File(path string) func(ctx *Context)
- 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 CompositeLogger
- func (l *CompositeLogger) Debug(v ...interface{})
- func (l *CompositeLogger) Debugf(format string, v ...interface{})
- func (l *CompositeLogger) Debugln(v ...interface{})
- func (l *CompositeLogger) Error(v ...interface{})
- func (l *CompositeLogger) Errorf(format string, v ...interface{})
- func (l *CompositeLogger) Errorln(v ...interface{})
- func (l *CompositeLogger) Info(v ...interface{})
- func (l *CompositeLogger) Infof(format string, v ...interface{})
- func (l *CompositeLogger) Infoln(v ...interface{})
- func (l *CompositeLogger) Warn(v ...interface{})
- func (l *CompositeLogger) Warnf(format string, v ...interface{})
- func (l *CompositeLogger) Warnln(v ...interface{})
- type Compress
- type Compresser
- type Context
- func (ctx *Context) Abort(status int, body ...string)
- func (ctx *Context) Action() interface{}
- func (ctx *Context) ActionTag(fieldName string) string
- func (ctx *Context) ActionValue() reflect.Value
- 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) DecodeJson(obj interface{}) error
- func (ctx *Context) DecodeXML(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) Queries() *Queries
- func (ctx *Context) Query(key string, defaults ...string) string
- func (ctx *Context) QueryBool(key string, defaults ...bool) bool
- func (ctx *Context) QueryEscape(key string, defaults ...string) string
- func (ctx *Context) QueryFloat32(key string, defaults ...float32) float32
- func (ctx *Context) QueryFloat64(key string, defaults ...float64) float64
- func (ctx *Context) QueryInt(key string, defaults ...int) int
- func (ctx *Context) QueryInt32(key string, defaults ...int32) int32
- func (ctx *Context) QueryInt64(key string, defaults ...int64) int64
- func (ctx *Context) QueryStrings(key string, defaults ...[]string) []string
- func (ctx *Context) QueryUint(key string, defaults ...uint) uint
- func (ctx *Context) QueryUint32(key string, defaults ...uint32) uint32
- func (ctx *Context) QueryUint64(key string, defaults ...uint64) uint64
- 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) ServeContent(path string, fileSystem http.FileSystem) error
- func (ctx *Context) ServeFile(path string) error
- func (ctx *Context) ServeJSON(obj interface{}) error
- func (ctx *Context) ServeJson(obj interface{}) error
- func (ctx *Context) ServeXML(obj interface{}) error
- func (ctx *Context) ServeXml(obj interface{}) error
- func (ctx *Context) SetRequest(req *http.Request)
- func (ctx *Context) Unauthorized()
- func (ctx *Context) WriteString(content string) (int, error)
- type Contexter
- type Cookies
- type Ctx
- type DefaultLogger
- func (t *DefaultLogger) Debug(v ...interface{})
- func (t *DefaultLogger) Debugf(format string, v ...interface{})
- func (t *DefaultLogger) Debugln(v ...interface{})
- func (t *DefaultLogger) Error(v ...interface{})
- func (t *DefaultLogger) Errorf(format string, v ...interface{})
- func (t *DefaultLogger) Errorln(v ...interface{})
- func (t *DefaultLogger) Info(v ...interface{})
- func (t *DefaultLogger) Infof(format string, v ...interface{})
- func (t *DefaultLogger) Infoln(v ...interface{})
- func (t *DefaultLogger) SetLevel(level int)
- func (t *DefaultLogger) Warn(v ...interface{})
- func (t *DefaultLogger) Warnf(format string, v ...interface{})
- func (t *DefaultLogger) Warnln(v ...interface{})
- type Deflate
- type ErrorKeyIsNotExist
- type ErrorWithCode
- 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{}, middlewares ...Handler)
- func (g *Group) Delete(url string, c interface{}, middlewares ...Handler)
- func (g *Group) Get(url string, c interface{}, middlewares ...Handler)
- func (g *Group) Group(p string, o interface{}, handlers ...Handler)
- func (g *Group) Head(url string, c interface{}, middlewares ...Handler)
- func (g *Group) Options(url string, c interface{}, middlewares ...Handler)
- func (g *Group) Patch(url string, c interface{}, middlewares ...Handler)
- func (g *Group) Post(url string, c interface{}, middlewares ...Handler)
- func (g *Group) Put(url string, c interface{}, middlewares ...Handler)
- func (g *Group) Route(methods interface{}, url string, c interface{}, middlewares ...Handler)
- func (g *Group) Trace(url string, c interface{}, middlewares ...Handler)
- 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 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 Queries
- func (f *Queries) Bool(key string) (bool, error)
- func (f *Queries) Escape(key string) (string, error)
- func (f *Queries) Float32(key string) (float32, error)
- func (f *Queries) Float64(key string) (float64, error)
- func (f *Queries) Int(key string) (int, error)
- func (f *Queries) Int32(key string) (int32, error)
- func (f *Queries) Int64(key string) (int64, error)
- func (f *Queries) MustBool(key string, defaults ...bool) bool
- func (f *Queries) MustEscape(key string, defaults ...string) string
- func (f *Queries) MustFloat32(key string, defaults ...float32) float32
- func (f *Queries) MustFloat64(key string, defaults ...float64) float64
- func (f *Queries) MustInt(key string, defaults ...int) int
- func (f *Queries) MustInt32(key string, defaults ...int32) int32
- func (f *Queries) MustInt64(key string, defaults ...int64) int64
- func (f *Queries) MustString(key string, defaults ...string) string
- func (f *Queries) MustStrings(key string, defaults ...[]string) []string
- func (f *Queries) MustUint(key string, defaults ...uint) uint
- func (f *Queries) MustUint32(key string, defaults ...uint32) uint32
- func (f *Queries) MustUint64(key string, defaults ...uint64) uint64
- func (f *Queries) String(key string) (string, error)
- func (f *Queries) Strings(key string) ([]string, error)
- func (f *Queries) Uint(key string) (uint, error)
- func (f *Queries) Uint32(key string) (uint32, error)
- func (f *Queries) Uint64(key string) (uint64, error)
- func (f *Queries) Values() url.Values
- 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{}, middlewares ...Handler)
- func (t *Tango) Delete(url string, c interface{}, middlewares ...Handler)
- func (t *Tango) Get(url string, c interface{}, middlewares ...Handler)
- func (t *Tango) Group(p string, o interface{}, handlers ...Handler)
- func (t *Tango) Head(url string, c interface{}, middlewares ...Handler)
- func (t *Tango) Logger() Logger
- func (t *Tango) Options(url string, c interface{}, middlewares ...Handler)
- func (t *Tango) Patch(url string, c interface{}, middlewares ...Handler)
- func (t *Tango) Post(url string, c interface{}, middlewares ...Handler)
- func (t *Tango) Put(url string, c interface{}, middlewares ...Handler)
- 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{}, middlewares ...Handler)
- func (t *Tango) Use(handlers ...Handler)
- func (t *Tango) UseHandler(handler http.Handler)
- type XML
- type XMLError
- type XMLString
- type Xml
Constants ¶
const ( HeaderAcceptEncoding = "Accept-Encoding" HeaderContentEncoding = "Content-Encoding" HeaderContentLength = "Content-Length" HeaderContentType = "Content-Type" HeaderVary = "Vary" )
some http headers
const ( LogLevelError = iota LogLevelWarn LogLevelInfo LogLevelDebug )
Variables ¶
var ( SupportMethods = []string{ "GET", "POST", "HEAD", "DELETE", "PUT", "OPTIONS", "TRACE", "PATCH", } PoolSize = 10 )
enumerates all supported HTTP methods
var ( // ClassicHandlers the default handlers ClassicHandlers = []Handler{ Logging(), Recovery(false), Compresses([]string{}), Static(StaticOptions{Prefix: "public"}), Return(), Param(), Contexts(), } )
Functions ¶
func NewSecureCookie ¶
NewSecureCookie generates a new secure cookie
Types ¶
type AbortError ¶
AbortError defines an interface to describe HTTP error
func Forbidden ¶
func Forbidden(content ...string) AbortError
Forbidden returns forbidden HTTP error
func InternalServerError ¶
func InternalServerError(content ...string) AbortError
InternalServerError returns internal server HTTP error
func NotSupported ¶
func NotSupported(content ...string) AbortError
NotSupported returns not supported HTTP error
func Unauthorized ¶
func Unauthorized(content ...string) AbortError
Unauthorized returns unauthorized HTTP error
type CompositeLogger ¶ added in v0.5.6
type CompositeLogger struct {
// contains filtered or unexported fields
}
CompositeLogger defines a composite loggers
func (*CompositeLogger) Debug ¶ added in v0.5.6
func (l *CompositeLogger) Debug(v ...interface{})
Debug implementes Logger interface
func (*CompositeLogger) Debugf ¶ added in v0.5.6
func (l *CompositeLogger) Debugf(format string, v ...interface{})
Debugf implementes Logger interface
func (*CompositeLogger) Debugln ¶ added in v0.5.6
func (l *CompositeLogger) Debugln(v ...interface{})
Debug implementes Logger interface
func (*CompositeLogger) Error ¶ added in v0.5.6
func (l *CompositeLogger) Error(v ...interface{})
Error implementes Logger interface
func (*CompositeLogger) Errorf ¶ added in v0.5.6
func (l *CompositeLogger) Errorf(format string, v ...interface{})
Errorf implementes Logger interface
func (*CompositeLogger) Errorln ¶ added in v0.5.6
func (l *CompositeLogger) Errorln(v ...interface{})
Errorln implementes Logger interface
func (*CompositeLogger) Info ¶ added in v0.5.6
func (l *CompositeLogger) Info(v ...interface{})
Info implementes Logger interface
func (*CompositeLogger) Infof ¶ added in v0.5.6
func (l *CompositeLogger) Infof(format string, v ...interface{})
Infof implementes Logger interface
func (*CompositeLogger) Infoln ¶ added in v0.5.6
func (l *CompositeLogger) Infoln(v ...interface{})
Infoln implementes Logger interface
func (*CompositeLogger) Warn ¶ added in v0.5.6
func (l *CompositeLogger) Warn(v ...interface{})
Warn implementes Logger interface
func (*CompositeLogger) Warnf ¶ added in v0.5.6
func (l *CompositeLogger) Warnf(format string, v ...interface{})
Warnf implementes Logger interface
func (*CompositeLogger) Warnln ¶ added in v0.5.6
func (l *CompositeLogger) Warnln(v ...interface{})
Warnln implementes Logger interface
type Compress ¶
type Compress struct{}
Compress implements auto Compresser
func (Compress) CompressType ¶
CompressType returns compress type
type Compresser ¶
type Compresser interface {
CompressType() string
}
Compresser defines the interface return compress type
type Context ¶
type Context struct { Logger ResponseWriter Result interface{} // contains filtered or unexported fields }
Context defines request and response context
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) ActionTag ¶ added in v0.5.6
ActionTag returns field tag on action struct TODO: cache the name
func (*Context) ActionValue ¶ added in v0.5.6
ActionValue returns action value
func (*Context) CookieBool ¶ added in v0.4.8
CookieBool returns cookie as bool with default
func (*Context) CookieEscape ¶ added in v0.4.8
CookieEscape returns cookie as escaped string with default
func (*Context) CookieFloat32 ¶ added in v0.4.8
CookieFloat32 returns cookie as float32 with default
func (*Context) CookieFloat64 ¶ added in v0.4.8
CookieFloat64 returns cookie as float64 with default
func (*Context) CookieInt32 ¶ added in v0.4.8
CookieInt32 returns cookie as int32 with default
func (*Context) CookieInt64 ¶ added in v0.4.8
CookieInt64 returns cookie as int64 with default
func (*Context) CookieUint ¶ added in v0.4.8
CookieUint returns cookie as uint with default
func (*Context) CookieUint32 ¶ added in v0.4.8
CookieUint32 returns cookie as uint32 with default
func (*Context) CookieUint64 ¶ added in v0.4.8
CookieUint64 returns cookie as uint64 with default
func (*Context) DecodeJSON ¶ added in v0.5.6
DecodeJSON decodes body as JSON format to obj
func (*Context) DecodeJson ¶ added in v0.4.8
DecodeJson decodes body as JSON format to obj Deprecated: use DecodeJSON instead
func (*Context) DecodeXml ¶ added in v0.4.8
DecodeXml decodes body as XML format to obj Deprecated: use DecodeXML instead
func (*Context) FormEscape ¶ added in v0.4.8
FormEscape returns request form as escaped string with default
func (*Context) FormFloat32 ¶ added in v0.4.8
FormFloat32 returns request form as float32 with default
func (*Context) FormFloat64 ¶ added in v0.4.8
FormFloat64 returns request form as float64 with default
func (*Context) FormStrings ¶ added in v0.4.8
FormStrings returns request form as strings with default
func (*Context) FormUint32 ¶ added in v0.4.8
FormUint32 returns request form as uint32 with default
func (*Context) FormUint64 ¶ added in v0.4.8
FormUint64 returns request form as uint64 with default
func (*Context) Next ¶
func (ctx *Context) Next()
Next call next middleware or action WARNING: don't invoke this method on action
func (*Context) NotModified ¶
func (ctx *Context) NotModified()
NotModified writes a 304 HTTP response
func (*Context) ParamEscape ¶ added in v0.4.8
ParamEscape returns request form as escaped string with default
func (*Context) ParamFloat32 ¶ added in v0.4.8
ParamFloat32 returns request form as float32 with default
func (*Context) ParamFloat64 ¶ added in v0.4.8
ParamFloat64 returns request form as float64 with default
func (*Context) ParamInt32 ¶ added in v0.4.8
ParamInt32 returns request form as int32 with default
func (*Context) ParamInt64 ¶ added in v0.4.8
ParamInt64 returns request form as int64 with default
func (*Context) ParamStrings ¶ added in v0.4.8
ParamStrings returns request form as slice of string with default
func (*Context) ParamUint32 ¶ added in v0.4.8
ParamUint32 returns request form as uint32 with default
func (*Context) ParamUint64 ¶ added in v0.4.8
ParamUint64 returns request form as uint64 with default
func (*Context) QueryEscape ¶ added in v0.5.6
QueryEscape returns request form as escaped string with default
func (*Context) QueryFloat32 ¶ added in v0.5.6
QueryFloat32 returns request form as float32 with default
func (*Context) QueryFloat64 ¶ added in v0.5.6
FormFloat64 returns request form as float64 with default
func (*Context) QueryInt32 ¶ added in v0.5.6
QueryInt32 returns request form as int32 with default
func (*Context) QueryInt64 ¶ added in v0.5.6
QueryInt64 returns request form as int64 with default
func (*Context) QueryStrings ¶ added in v0.5.6
QueryStrings returns request form as strings with default
func (*Context) QueryUint32 ¶ added in v0.5.6
QueryUint32 returns request form as uint32 with default
func (*Context) QueryUint64 ¶ added in v0.5.6
QueryUint64 returns request form as uint64 with default
func (*Context) SaveToFile ¶ added in v0.4.3
SaveToFile saves the HTTP post file form to local file path
func (*Context) SecureCookies ¶
SecureCookies generates a secret cookie
func (*Context) ServeContent ¶ added in v0.5.6
func (ctx *Context) ServeContent(path string, fileSystem http.FileSystem) error
ServeContent serve content
func (*Context) ServeJson ¶
ServeJson serves marshaled JSON content from obj Deprecated: use ServeJSON instead
func (*Context) ServeXml ¶
ServeXml serves marshaled XML content from obj Deprecated: use ServeXML instead
func (*Context) SetRequest ¶ added in v0.5.6
SetRequest sets the request to context
func (*Context) Unauthorized ¶
func (ctx *Context) Unauthorized()
Unauthorized writes a 401 HTTP response
type Contexter ¶
type Contexter interface {
SetContext(*Context)
}
Contexter describes an interface to set *Context
type Cookies ¶
type Cookies interface { Set Get(string) *http.Cookie Set(*http.Cookie) Expire(string, time.Time) Del(string) }
Cookies describes cookie interface
type Ctx ¶
type Ctx struct {
*Context
}
Ctx implements Contexter
func (*Ctx) SetContext ¶
SetContext set *Context to action struct
type DefaultLogger ¶ added in v0.5.6
func NewDefaultLogger ¶ added in v0.5.6
func NewDefaultLogger(out io.Writer) *DefaultLogger
NewLogger use the default logger with special writer
func (*DefaultLogger) Debug ¶ added in v0.5.6
func (t *DefaultLogger) Debug(v ...interface{})
func (*DefaultLogger) Debugf ¶ added in v0.5.6
func (t *DefaultLogger) Debugf(format string, v ...interface{})
func (*DefaultLogger) Debugln ¶ added in v0.5.6
func (t *DefaultLogger) Debugln(v ...interface{})
func (*DefaultLogger) Error ¶ added in v0.5.6
func (t *DefaultLogger) Error(v ...interface{})
func (*DefaultLogger) Errorf ¶ added in v0.5.6
func (t *DefaultLogger) Errorf(format string, v ...interface{})
func (*DefaultLogger) Errorln ¶ added in v0.5.6
func (t *DefaultLogger) Errorln(v ...interface{})
func (*DefaultLogger) Info ¶ added in v0.5.6
func (t *DefaultLogger) Info(v ...interface{})
func (*DefaultLogger) Infof ¶ added in v0.5.6
func (t *DefaultLogger) Infof(format string, v ...interface{})
func (*DefaultLogger) Infoln ¶ added in v0.5.6
func (t *DefaultLogger) Infoln(v ...interface{})
func (*DefaultLogger) SetLevel ¶ added in v0.5.6
func (t *DefaultLogger) SetLevel(level int)
func (*DefaultLogger) Warn ¶ added in v0.5.6
func (t *DefaultLogger) Warn(v ...interface{})
func (*DefaultLogger) Warnf ¶ added in v0.5.6
func (t *DefaultLogger) Warnf(format string, v ...interface{})
func (*DefaultLogger) Warnln ¶ added in v0.5.6
func (t *DefaultLogger) Warnln(v ...interface{})
type Deflate ¶
type Deflate struct{}
Deflate implements deflate Compresser
func (Deflate) CompressType ¶
CompressType returns compress type
type ErrorKeyIsNotExist ¶ added in v0.5.6
type ErrorKeyIsNotExist struct {
Key string
}
func (ErrorKeyIsNotExist) Error ¶ added in v0.5.6
func (e ErrorKeyIsNotExist) Error() string
type ErrorWithCode ¶ added in v0.5.6
ErrorWithCode descripts an error that with error code
type Forms ¶ added in v0.4.6
Forms a new enhancement of http.Request
func (*Forms) MustEscape ¶ added in v0.4.8
MustEscape returns request form as escaped string with default
func (*Forms) MustFloat32 ¶ added in v0.4.6
MustFloat32 returns request form as float32 with default
func (*Forms) MustFloat64 ¶ added in v0.4.6
MustFloat64 returns request form as float64 with default
func (*Forms) MustString ¶ added in v0.4.6
MustString returns request form as string with default
func (*Forms) MustStrings ¶ added in v0.4.8
MustStrings returns request form as strings with default
func (*Forms) MustUint32 ¶ added in v0.4.6
MustUint32 returns request form as uint32 with default
func (*Forms) MustUint64 ¶ added in v0.4.6
MustUint64 returns request form as uint64 with default
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group defines a route group
type HandlerFunc ¶
type HandlerFunc func(ctx *Context)
HandlerFunc describes the handle function
func Compresses ¶
func Compresses(exts []string) HandlerFunc
Compresses defines a middleware to compress HTTP response
func Contexts ¶
func Contexts() HandlerFunc
Contexts returns a middleware to inject Context to action struct
func Errors ¶
func Errors() HandlerFunc
Errors returns default errorhandler, you can use your self handler
func Prefix ¶ added in v0.2.9
func Prefix(prefix string, handler Handler) HandlerFunc
Prefix provides a middleware to wrap another middleware with a prefix URL TODO: regex prefix
func Recovery ¶
func Recovery(debug bool) HandlerFunc
Recovery returns a middleware which catch panics and log them
func Static ¶
func Static(opts ...StaticOptions) HandlerFunc
Static return a middleware for serving static files
func WrapAfter ¶
func WrapAfter(handler http.Handler) HandlerFunc
WrapAfter wraps a http standard handler to tango's after action executes
func WrapBefore ¶
func WrapBefore(handler http.Handler) HandlerFunc
WrapBefore wraps a http standard handler to tango's before action executes
type JSON ¶ added in v0.5.6
type JSON struct{}
JSON describes return JSON type
func (JSON) ResponseType ¶ added in v0.5.6
ResponseType implementes ResponseTyper
type LogInterface ¶
type LogInterface interface {
SetLogger(Logger)
}
LogInterface defines logger interface to inject logger to struct
type Logger ¶
type Logger interface { Debugf(format string, v ...interface{}) Debug(v ...interface{}) Debugln(v ...interface{}) Infof(format string, v ...interface{}) Info(v ...interface{}) Infoln(v ...interface{}) Warnf(format string, v ...interface{}) Warn(v ...interface{}) Warnln(v ...interface{}) Errorf(format string, v ...interface{}) Error(v ...interface{}) Errorln(v ...interface{}) }
Logger defines the logger interface for tango use
func NewCompositeLogger ¶ added in v0.5.6
NewCompositeLogger creates a composite loggers
type Paramer ¶
type Paramer interface {
SetParams([]param)
}
Paramer defines an interface to get params
type Params ¶
type Params []param
Params defines params of http request
func (*Params) MustEscape ¶ added in v0.4.8
MustEscape returns request form as escaped string with default
func (*Params) MustFloat32 ¶ added in v0.4.6
MustFloat32 returns request form as float32 with default
func (*Params) MustFloat64 ¶ added in v0.4.6
MustFloat64 returns request form as float64 with default
func (*Params) MustString ¶ added in v0.4.6
MustString returns request form as slice of string with default
func (*Params) MustStrings ¶ added in v0.4.8
MustStrings returns request form as slice of string with default
func (*Params) MustUint32 ¶ added in v0.4.6
MustUint32 returns request form as uint32 with default
func (*Params) MustUint64 ¶ added in v0.4.6
MustUint64 returns request form as uint64 with default
type Queries ¶ added in v0.5.6
Queries a new enhancement of http.Request
func (*Queries) MustEscape ¶ added in v0.5.6
MustEscape returns request form as escaped string with default
func (*Queries) MustFloat32 ¶ added in v0.5.6
MustFloat32 returns request form as float32 with default
func (*Queries) MustFloat64 ¶ added in v0.5.6
MustFloat64 returns request form as float64 with default
func (*Queries) MustString ¶ added in v0.5.6
MustString returns request form as string with default
func (*Queries) MustStrings ¶ added in v0.5.6
MustStrings returns request form as strings with default
func (*Queries) MustUint32 ¶ added in v0.5.6
MustUint32 returns request form as uint32 with default
func (*Queries) MustUint64 ¶ added in v0.5.6
MustUint64 returns request form as uint64 with default
type ResponseTyper ¶
type ResponseTyper interface {
ResponseType() int
}
ResponseTyper describes reponse type
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 Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route defines HTTP route
func NewRoute ¶
func NewRoute(v interface{}, t reflect.Type, method reflect.Value, tp RouteType, handlers []Handler) *Route
NewRoute returns a route
type RouteType ¶
type RouteType byte
RouteType defines route types
const ( FuncRoute RouteType = iota + 1 // 1 func () FuncHTTPRoute // 2 func (http.ResponseWriter, *http.Request) FuncReqRoute // 3 func (*http.Request) FuncResponseRoute // 4 func (http.ResponseWriter) FuncCtxRoute // 5 func (*tango.Context) StructRoute // 6 func (st) <Get>() StructPtrRoute // 7 func (*struct) <Get>() )
enumerates route types
type Router ¶
type Router interface { Route(methods interface{}, path string, handler interface{}, middlewares ...Handler) Match(requestPath, method string) (*Route, Params) }
Router describes the interface of route
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 }
Set describes a set interface
type StaticOptions ¶
type StaticOptions struct { RootPath string Prefix string IndexFiles []string ListDir bool FilterExts []string // FileSystem is the interface for supporting any implmentation of file system. FileSystem http.FileSystem }
StaticOptions defines Static middleware's options
func (*StaticOptions) IsFilterExt ¶ added in v0.5.6
func (s *StaticOptions) IsFilterExt(rPath string) bool
IsFilterExt decribes if rPath's ext match filter ext
type StatusResult ¶ added in v0.4.8
type StatusResult struct { Code int Result interface{} }
StatusResult describes http response
type Tango ¶
type Tango struct { http.Server Router ErrHandler Handler // contains filtered or unexported fields }
Tango describes tango object
func NewWithLog ¶
NewWithLog creates tango with the special logger and handlers
func (*Tango) Run ¶
func (t *Tango) Run(args ...interface{})
Run the http server. Listening on os.GetEnv("PORT") or 8000 by default.
func (*Tango) ServeHTTP ¶
func (t *Tango) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP implementes net/http interface so that it could run with net/http
func (*Tango) UseHandler ¶
UseHandler adds a standard http handler to tango's
type XML ¶ added in v0.5.6
type XML struct{}
XML descirbes return XML type
func (XML) ResponseType ¶ added in v0.5.6
ResponseType implementes ResponseTyper