tango: gitea.com/lunny/tango Index | Files

package tango

import "gitea.com/lunny/tango"

Index

Package Files

compress.go context.go cookie.go doc.go error.go file.go form.go group.go logger.go param.go pool.go prefix.go query.go recovery.go response.go return.go router.go static.go tan.go

Constants

const (
    HeaderAcceptEncoding  = "Accept-Encoding"
    HeaderContentEncoding = "Content-Encoding"
    HeaderContentLength   = "Content-Length"
    HeaderContentType     = "Content-Type"
    HeaderVary            = "Vary"
)

some http headers

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(),
    }
)

func Content Uses

func Content(path string, fs http.FileSystem) func(ctx *Context)

Content returns a handle to serve a file

func Dir Uses

func Dir(dir string) func(ctx *Context)

Dir returns a handle to serve a directory

func File Uses

func File(path string) func(ctx *Context)

File returns a handle to serve a file

func NewCookie Uses

func NewCookie(name string, value string, age ...int64) *http.Cookie

NewCookie return a http.Cookie via give name and value

func NewSecureCookie Uses

func NewSecureCookie(secret, name string, val string, age ...int64) *http.Cookie

NewSecureCookie generates a new secure cookie

func Version Uses

func Version() string

Version returns tango's version

type AbortError Uses

type AbortError interface {
    error
    Code() int
}

AbortError defines an interface to describe HTTP error

func Abort Uses

func Abort(code int, content ...string) AbortError

Abort returns an AbortError

func Forbidden Uses

func Forbidden(content ...string) AbortError

Forbidden returns forbidden HTTP error

func InternalServerError Uses

func InternalServerError(content ...string) AbortError

InternalServerError returns internal server HTTP error

func NotFound Uses

func NotFound(content ...string) AbortError

NotFound returns not found HTTP error

func NotSupported Uses

func NotSupported(content ...string) AbortError

NotSupported returns not supported HTTP error

func Unauthorized Uses

func Unauthorized(content ...string) AbortError

Unauthorized returns unauthorized HTTP error

type CompositeLogger Uses

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

CompositeLogger defines a composite loggers

func (*CompositeLogger) Debug Uses

func (l *CompositeLogger) Debug(v ...interface{})

Debug implementes Logger interface

func (*CompositeLogger) Debugf Uses

func (l *CompositeLogger) Debugf(format string, v ...interface{})

Debugf implementes Logger interface

func (*CompositeLogger) Error Uses

func (l *CompositeLogger) Error(v ...interface{})

Error implementes Logger interface

func (*CompositeLogger) Errorf Uses

func (l *CompositeLogger) Errorf(format string, v ...interface{})

Errorf implementes Logger interface

func (*CompositeLogger) Info Uses

func (l *CompositeLogger) Info(v ...interface{})

Info implementes Logger interface

func (*CompositeLogger) Infof Uses

func (l *CompositeLogger) Infof(format string, v ...interface{})

Infof implementes Logger interface

func (*CompositeLogger) Warn Uses

func (l *CompositeLogger) Warn(v ...interface{})

Warn implementes Logger interface

func (*CompositeLogger) Warnf Uses

func (l *CompositeLogger) Warnf(format string, v ...interface{})

Warnf implementes Logger interface

type Compress Uses

type Compress struct{}

Compress implements auto Compresser

func (Compress) CompressType Uses

func (Compress) CompressType() string

CompressType returns compress type

type Compresser Uses

type Compresser interface {
    CompressType() string
}

Compresser defines the interface return compress type

type Context Uses

type Context struct {
    Logger

    ResponseWriter

    Result interface{}
    // contains filtered or unexported fields
}

Context defines request and response context

func (*Context) Abort Uses

func (ctx *Context) Abort(status int, body ...string)

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) Action Uses

func (ctx *Context) Action() interface{}

Action returns action

func (*Context) ActionTag Uses

func (ctx *Context) ActionTag(fieldName string) string

ActionTag returns field tag on action struct TODO: cache the name

func (*Context) ActionValue Uses

func (ctx *Context) ActionValue() reflect.Value

ActionValue returns action value

func (*Context) Body Uses

func (ctx *Context) Body() ([]byte, error)

Body returns body's content

func (*Context) Cookie Uses

func (ctx *Context) Cookie(key string, defaults ...string) string

Cookie returns cookie as string with default

func (*Context) CookieBool Uses

func (ctx *Context) CookieBool(key string, defaults ...bool) bool

CookieBool returns cookie as bool with default

func (*Context) CookieEscape Uses

func (ctx *Context) CookieEscape(key string, defaults ...string) string

CookieEscape returns cookie as escaped string with default

func (*Context) CookieFloat32 Uses

func (ctx *Context) CookieFloat32(key string, defaults ...float32) float32

CookieFloat32 returns cookie as float32 with default

func (*Context) CookieFloat64 Uses

func (ctx *Context) CookieFloat64(key string, defaults ...float64) float64

CookieFloat64 returns cookie as float64 with default

func (*Context) CookieInt Uses

func (ctx *Context) CookieInt(key string, defaults ...int) int

CookieInt returns cookie as int with default

func (*Context) CookieInt32 Uses

func (ctx *Context) CookieInt32(key string, defaults ...int32) int32

CookieInt32 returns cookie as int32 with default

func (*Context) CookieInt64 Uses

func (ctx *Context) CookieInt64(key string, defaults ...int64) int64

CookieInt64 returns cookie as int64 with default

func (*Context) CookieUint Uses

func (ctx *Context) CookieUint(key string, defaults ...uint) uint

CookieUint returns cookie as uint with default

func (*Context) CookieUint32 Uses

func (ctx *Context) CookieUint32(key string, defaults ...uint32) uint32

CookieUint32 returns cookie as uint32 with default

func (*Context) CookieUint64 Uses

func (ctx *Context) CookieUint64(key string, defaults ...uint64) uint64

CookieUint64 returns cookie as uint64 with default

func (*Context) Cookies Uses

func (ctx *Context) Cookies() Cookies

Cookies returns the cookies

func (*Context) DecodeJSON Uses

func (ctx *Context) DecodeJSON(obj interface{}) error

DecodeJSON decodes body as JSON format to obj

func (*Context) DecodeJson Uses

func (ctx *Context) DecodeJson(obj interface{}) error

DecodeJson decodes body as JSON format to obj Deprecated: use DecodeJSON instead

func (*Context) DecodeXML Uses

func (ctx *Context) DecodeXML(obj interface{}) error

DecodeXML decodes body as XML format to obj

func (*Context) DecodeXml Uses

func (ctx *Context) DecodeXml(obj interface{}) error

DecodeXml decodes body as XML format to obj Deprecated: use DecodeXML instead

func (*Context) Download Uses

func (ctx *Context) Download(fpath string) error

Download provides a locale file to http client

func (*Context) Form Uses

func (ctx *Context) Form(key string, defaults ...string) string

Form returns request form as string with default

func (*Context) FormBool Uses

func (ctx *Context) FormBool(key string, defaults ...bool) bool

FormBool returns request form as bool with default

func (*Context) FormEscape Uses

func (ctx *Context) FormEscape(key string, defaults ...string) string

FormEscape returns request form as escaped string with default

func (*Context) FormFloat32 Uses

func (ctx *Context) FormFloat32(key string, defaults ...float32) float32

FormFloat32 returns request form as float32 with default

func (*Context) FormFloat64 Uses

func (ctx *Context) FormFloat64(key string, defaults ...float64) float64

FormFloat64 returns request form as float64 with default

func (*Context) FormInt Uses

func (ctx *Context) FormInt(key string, defaults ...int) int

FormInt returns request form as int with default

func (*Context) FormInt32 Uses

func (ctx *Context) FormInt32(key string, defaults ...int32) int32

FormInt32 returns request form as int32 with default

func (*Context) FormInt64 Uses

func (ctx *Context) FormInt64(key string, defaults ...int64) int64

FormInt64 returns request form as int64 with default

func (*Context) FormStrings Uses

func (ctx *Context) FormStrings(key string, defaults ...[]string) []string

FormStrings returns request form as strings with default

func (*Context) FormTrimmed Uses

func (ctx *Context) FormTrimmed(key string, defaults ...string) string

FormTrimmed returns request form as string with default and trimmed spaces

func (*Context) FormUint Uses

func (ctx *Context) FormUint(key string, defaults ...uint) uint

FormUint returns request form as uint with default

func (*Context) FormUint32 Uses

func (ctx *Context) FormUint32(key string, defaults ...uint32) uint32

FormUint32 returns request form as uint32 with default

func (*Context) FormUint64 Uses

func (ctx *Context) FormUint64(key string, defaults ...uint64) uint64

FormUint64 returns request form as uint64 with default

func (*Context) Forms Uses

func (ctx *Context) Forms() *Forms

Forms returns the query/body names and values

func (*Context) HandleError Uses

func (ctx *Context) HandleError()

HandleError handles errors

func (*Context) IP Uses

func (ctx *Context) IP() string

IP returns remote IP

func (*Context) IsAjax Uses

func (ctx *Context) IsAjax() bool

IsAjax returns if the request is an ajax request

func (*Context) Next Uses

func (ctx *Context) Next()

Next call next middleware or action WARNING: don't invoke this method on action

func (*Context) NotFound Uses

func (ctx *Context) NotFound(message ...string)

NotFound writes a 404 HTTP response

func (*Context) NotModified Uses

func (ctx *Context) NotModified()

NotModified writes a 304 HTTP response

func (*Context) Param Uses

func (ctx *Context) Param(key string, defaults ...string) string

Param returns request form as string with default

func (*Context) ParamBool Uses

func (ctx *Context) ParamBool(key string, defaults ...bool) bool

ParamBool returns request form as bool with default

func (*Context) ParamEscape Uses

func (ctx *Context) ParamEscape(key string, defaults ...string) string

ParamEscape returns request form as escaped string with default

func (*Context) ParamFloat32 Uses

func (ctx *Context) ParamFloat32(key string, defaults ...float32) float32

ParamFloat32 returns request form as float32 with default

func (*Context) ParamFloat64 Uses

func (ctx *Context) ParamFloat64(key string, defaults ...float64) float64

ParamFloat64 returns request form as float64 with default

func (*Context) ParamInt Uses

func (ctx *Context) ParamInt(key string, defaults ...int) int

ParamInt returns request form as int with default

func (*Context) ParamInt32 Uses

func (ctx *Context) ParamInt32(key string, defaults ...int32) int32

ParamInt32 returns request form as int32 with default

func (*Context) ParamInt64 Uses

func (ctx *Context) ParamInt64(key string, defaults ...int64) int64

ParamInt64 returns request form as int64 with default

func (*Context) ParamStrings Uses

func (ctx *Context) ParamStrings(key string, defaults ...[]string) []string

ParamStrings returns request form as slice of string with default

func (*Context) ParamUint Uses

func (ctx *Context) ParamUint(key string, defaults ...uint) uint

ParamUint returns request form as uint with default

func (*Context) ParamUint32 Uses

func (ctx *Context) ParamUint32(key string, defaults ...uint32) uint32

ParamUint32 returns request form as uint32 with default

func (*Context) ParamUint64 Uses

func (ctx *Context) ParamUint64(key string, defaults ...uint64) uint64

ParamUint64 returns request form as uint64 with default

func (*Context) Params Uses

func (ctx *Context) Params() *Params

Params returns the URL params

func (*Context) Queries Uses

func (ctx *Context) Queries() *Queries

Queries returns the query names and values

func (*Context) Query Uses

func (ctx *Context) Query(key string, defaults ...string) string

Query returns request form as string with default

func (*Context) QueryBool Uses

func (ctx *Context) QueryBool(key string, defaults ...bool) bool

FormBool returns request form as bool with default

func (*Context) QueryEscape Uses

func (ctx *Context) QueryEscape(key string, defaults ...string) string

QueryEscape returns request form as escaped string with default

func (*Context) QueryFloat32 Uses

func (ctx *Context) QueryFloat32(key string, defaults ...float32) float32

QueryFloat32 returns request form as float32 with default

func (*Context) QueryFloat64 Uses

func (ctx *Context) QueryFloat64(key string, defaults ...float64) float64

FormFloat64 returns request form as float64 with default

func (*Context) QueryInt Uses

func (ctx *Context) QueryInt(key string, defaults ...int) int

QueryInt returns request form as int with default

func (*Context) QueryInt32 Uses

func (ctx *Context) QueryInt32(key string, defaults ...int32) int32

QueryInt32 returns request form as int32 with default

func (*Context) QueryInt64 Uses

func (ctx *Context) QueryInt64(key string, defaults ...int64) int64

QueryInt64 returns request form as int64 with default

func (*Context) QueryStrings Uses

func (ctx *Context) QueryStrings(key string, defaults ...[]string) []string

QueryStrings returns request form as strings with default

func (*Context) QueryUint Uses

func (ctx *Context) QueryUint(key string, defaults ...uint) uint

QueryUint returns request form as uint with default

func (*Context) QueryUint32 Uses

func (ctx *Context) QueryUint32(key string, defaults ...uint32) uint32

QueryUint32 returns request form as uint32 with default

func (*Context) QueryUint64 Uses

func (ctx *Context) QueryUint64(key string, defaults ...uint64) uint64

QueryUint64 returns request form as uint64 with default

func (*Context) Redirect Uses

func (ctx *Context) Redirect(url string, status ...int)

Redirect redirects the request to another URL

func (*Context) Req Uses

func (ctx *Context) Req() *http.Request

Req returns current HTTP Request information

func (*Context) Route Uses

func (ctx *Context) Route() *Route

Route returns route

func (*Context) SaveToFile Uses

func (ctx *Context) SaveToFile(formName, savePath string) error

SaveToFile saves the HTTP post file form to local file path

func (*Context) SecureCookies Uses

func (ctx *Context) SecureCookies(secret string) Cookies

SecureCookies generates a secret cookie

func (*Context) ServeContent Uses

func (ctx *Context) ServeContent(path string, fileSystem http.FileSystem) error

ServeContent serve content

func (*Context) ServeFile Uses

func (ctx *Context) ServeFile(path string) error

ServeFile serves a file

func (*Context) ServeJSON Uses

func (ctx *Context) ServeJSON(obj interface{}) error

ServeJSON serves marshaled JSON content from obj

func (*Context) ServeJson Uses

func (ctx *Context) ServeJson(obj interface{}) error

ServeJson serves marshaled JSON content from obj Deprecated: use ServeJSON instead

func (*Context) ServeXML Uses

func (ctx *Context) ServeXML(obj interface{}) error

ServeXML serves marshaled XML content from obj

func (*Context) ServeXml Uses

func (ctx *Context) ServeXml(obj interface{}) error

ServeXml serves marshaled XML content from obj Deprecated: use ServeXML instead

func (*Context) SetRequest Uses

func (ctx *Context) SetRequest(req *http.Request)

SetRequest sets the request to context

func (*Context) Unauthorized Uses

func (ctx *Context) Unauthorized()

Unauthorized writes a 401 HTTP response

func (*Context) WriteString Uses

func (ctx *Context) WriteString(content string) (int, error)

WriteString writes a string to response write

type Contexter Uses

type Contexter interface {
    SetContext(*Context)
}

Contexter describes an interface to set *Context

type Cookies Uses

type Cookies interface {
    Set
    Get(string) *http.Cookie
    Set(*http.Cookie)
    Expire(string, time.Time)
    Del(string)
}

Cookies describes cookie interface

type Ctx Uses

type Ctx struct {
    *Context
}

Ctx implements Contexter

func (*Ctx) SetContext Uses

func (c *Ctx) SetContext(ctx *Context)

SetContext set *Context to action struct

type Deflate Uses

type Deflate struct{}

Deflate implements deflate Compresser

func (Deflate) CompressType Uses

func (Deflate) CompressType() string

CompressType returns compress type

type ErrorKeyIsNotExist Uses

type ErrorKeyIsNotExist struct {
    Key string
}

func (ErrorKeyIsNotExist) Error Uses

func (e ErrorKeyIsNotExist) Error() string

type ErrorWithCode Uses

type ErrorWithCode interface {
    error
    ErrorCode() int
}

ErrorWithCode descripts an error that with error code

type Forms Uses

type Forms http.Request

Forms a new enhancement of http.Request

func (*Forms) Bool Uses

func (f *Forms) Bool(key string) (bool, error)

Bool returns request form as bool

func (*Forms) Escape Uses

func (f *Forms) Escape(key string) (string, error)

Escape returns request form as escaped string

func (*Forms) Float32 Uses

func (f *Forms) Float32(key string) (float32, error)

Float32 returns request form as float32

func (*Forms) Float64 Uses

func (f *Forms) Float64(key string) (float64, error)

Float64 returns request form as float64

func (*Forms) Int Uses

func (f *Forms) Int(key string) (int, error)

Int returns request form as int

func (*Forms) Int32 Uses

func (f *Forms) Int32(key string) (int32, error)

Int32 returns request form as int32

func (*Forms) Int64 Uses

func (f *Forms) Int64(key string) (int64, error)

Int64 returns request form as int64

func (*Forms) MustBool Uses

func (f *Forms) MustBool(key string, defaults ...bool) bool

MustBool returns request form as bool with default

func (*Forms) MustEscape Uses

func (f *Forms) MustEscape(key string, defaults ...string) string

MustEscape returns request form as escaped string with default

func (*Forms) MustFloat32 Uses

func (f *Forms) MustFloat32(key string, defaults ...float32) float32

MustFloat32 returns request form as float32 with default

func (*Forms) MustFloat64 Uses

func (f *Forms) MustFloat64(key string, defaults ...float64) float64

MustFloat64 returns request form as float64 with default

func (*Forms) MustInt Uses

func (f *Forms) MustInt(key string, defaults ...int) int

MustInt returns request form as int with default

func (*Forms) MustInt32 Uses

func (f *Forms) MustInt32(key string, defaults ...int32) int32

MustInt32 returns request form as int32 with default

func (*Forms) MustInt64 Uses

func (f *Forms) MustInt64(key string, defaults ...int64) int64

MustInt64 returns request form as int64 with default

func (*Forms) MustString Uses

func (f *Forms) MustString(key string, defaults ...string) string

MustString returns request form as string with default

func (*Forms) MustStrings Uses

func (f *Forms) MustStrings(key string, defaults ...[]string) []string

MustStrings returns request form as strings with default

func (*Forms) MustTrimmed Uses

func (f *Forms) MustTrimmed(key string, defaults ...string) string

MustTrimmed returns request form as string with default

func (*Forms) MustUint Uses

func (f *Forms) MustUint(key string, defaults ...uint) uint

MustUint returns request form as uint with default

func (*Forms) MustUint32 Uses

func (f *Forms) MustUint32(key string, defaults ...uint32) uint32

MustUint32 returns request form as uint32 with default

func (*Forms) MustUint64 Uses

func (f *Forms) MustUint64(key string, defaults ...uint64) uint64

MustUint64 returns request form as uint64 with default

func (*Forms) String Uses

func (f *Forms) String(key string) (string, error)

String returns request form as string

func (*Forms) Strings Uses

func (f *Forms) Strings(key string) ([]string, error)

Strings returns request form as strings

func (*Forms) Trimmed Uses

func (f *Forms) Trimmed(key string) (string, error)

TrimSpace returns request form as string with trimed spaces left and right

func (*Forms) Uint Uses

func (f *Forms) Uint(key string) (uint, error)

Uint returns request form as uint

func (*Forms) Uint32 Uses

func (f *Forms) Uint32(key string) (uint32, error)

Uint32 returns request form as uint32

func (*Forms) Uint64 Uses

func (f *Forms) Uint64(key string) (uint64, error)

Uint64 returns request form as uint64

func (*Forms) Values Uses

func (f *Forms) Values() url.Values

Values returns http.Request values

type GZip Uses

type GZip struct{}

GZip implements gzip Compresser

func (GZip) CompressType Uses

func (GZip) CompressType() string

CompressType returns compress type

type Group Uses

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

Group defines a route group

func NewGroup Uses

func NewGroup() *Group

NewGroup creates a route group

func (*Group) Any Uses

func (g *Group) Any(url string, c interface{}, middlewares ...Handler)

Any addes the default mehtods route to this group

func (*Group) Delete Uses

func (g *Group) Delete(url string, c interface{}, middlewares ...Handler)

Delete addes a DELETE route to this group

func (*Group) Get Uses

func (g *Group) Get(url string, c interface{}, middlewares ...Handler)

Get addes a GET route to this group

func (*Group) Group Uses

func (g *Group) Group(p string, o interface{}, handlers ...Handler)

Group defines group's child group

func (*Group) Head Uses

func (g *Group) Head(url string, c interface{}, middlewares ...Handler)

Head addes a HEAD route to this group

func (*Group) Options Uses

func (g *Group) Options(url string, c interface{}, middlewares ...Handler)

Options addes a OPTIONS route to this group

func (*Group) Patch Uses

func (g *Group) Patch(url string, c interface{}, middlewares ...Handler)

Patch addes a PATCH route to this group

func (*Group) Post Uses

func (g *Group) Post(url string, c interface{}, middlewares ...Handler)

Post addes a POST route to this group

func (*Group) Put Uses

func (g *Group) Put(url string, c interface{}, middlewares ...Handler)

Put addes a PUT route to this group

func (*Group) Route Uses

func (g *Group) Route(methods interface{}, url string, c interface{}, middlewares ...Handler)

Route defines a customerize route to this group

func (*Group) Trace Uses

func (g *Group) Trace(url string, c interface{}, middlewares ...Handler)

Trace addes a TRACE route to this group

func (*Group) Use Uses

func (g *Group) Use(handlers ...Handler)

Use set the middlewares to apply to this group's routes

type Handler Uses

type Handler interface {
    Handle(*Context)
}

Handler defines middleware interface

type HandlerFunc Uses

type HandlerFunc func(ctx *Context)

HandlerFunc describes the handle function

func Compresses Uses

func Compresses(exts []string) HandlerFunc

Compresses defines a middleware to compress HTTP response

func Contexts Uses

func Contexts() HandlerFunc

Contexts returns a middleware to inject Context to action struct

func Errors Uses

func Errors() HandlerFunc

Errors returns default errorhandler, you can use your self handler

func Logging Uses

func Logging() HandlerFunc

Logging returns handler to log informations

func Param Uses

func Param() HandlerFunc

Param returns params handle to operate param

func Prefix Uses

func Prefix(prefix string, handler Handler) HandlerFunc

Prefix provides a middleware to wrap another middleware with a prefix URL TODO: regex prefix

func Recovery Uses

func Recovery(debug bool) HandlerFunc

Recovery returns a middleware which catch panics and log them

func Return Uses

func Return() HandlerFunc

Return returns a tango middleware to handler return values

func Static Uses

func Static(opts ...StaticOptions) HandlerFunc

Static return a middleware for serving static files

func WrapAfter Uses

func WrapAfter(handler http.Handler) HandlerFunc

WrapAfter wraps a http standard handler to tango's after action executes

func WrapBefore Uses

func WrapBefore(handler http.Handler) HandlerFunc

WrapBefore wraps a http standard handler to tango's before action executes

func (HandlerFunc) Handle Uses

func (h HandlerFunc) Handle(ctx *Context)

Handle executes the handler

type JSON Uses

type JSON struct{}

JSON describes return JSON type

func (JSON) ResponseType Uses

func (JSON) ResponseType() int

ResponseType implementes ResponseTyper

type Json Uses

type Json struct{}

Json describes return JSON type Deprecated: use JSON instead

func (Json) ResponseType Uses

func (Json) ResponseType() int

ResponseType implementes ResponseTyper

type Log Uses

type Log struct {
    Logger
}

Log implementes LogInterface

func (*Log) SetLogger Uses

func (l *Log) SetLogger(log Logger)

SetLogger implementes LogInterface

type LogInterface Uses

type LogInterface interface {
    SetLogger(Logger)
}

LogInterface defines logger interface to inject logger to struct

type Logger Uses

type Logger interface {
    Debugf(format string, v ...interface{})
    Debug(v ...interface{})
    Infof(format string, v ...interface{})
    Info(v ...interface{})
    Warnf(format string, v ...interface{})
    Warn(v ...interface{})
    Errorf(format string, v ...interface{})
    Error(v ...interface{})
}

Logger defines the logger interface for tango use

func NewCompositeLogger Uses

func NewCompositeLogger(logs ...Logger) Logger

NewCompositeLogger creates a composite loggers

func NewLogger Uses

func NewLogger(out io.Writer) Logger

NewLogger use the default logger with special writer

type Paramer Uses

type Paramer interface {
    SetParams([]param)
}

Paramer defines an interface to get params

type Params Uses

type Params []param

Params defines params of http request

func (*Params) Bool Uses

func (p *Params) Bool(key string) (bool, error)

Bool returns request form as bool

func (*Params) Escape Uses

func (p *Params) Escape(key string) (string, error)

Escape returns request form as escaped string

func (*Params) Float32 Uses

func (p *Params) Float32(key string) (float32, error)

Float32 returns request form as float32

func (*Params) Float64 Uses

func (p *Params) Float64(key string) (float64, error)

Float64 returns request form as float64

func (*Params) Get Uses

func (p *Params) Get(key string) string

Get returns request form as string

func (*Params) Int Uses

func (p *Params) Int(key string) (int, error)

Int returns request form as int

func (*Params) Int32 Uses

func (p *Params) Int32(key string) (int32, error)

Int32 returns request form as int32

func (*Params) Int64 Uses

func (p *Params) Int64(key string) (int64, error)

Int64 returns request form as int64

func (*Params) MustBool Uses

func (p *Params) MustBool(key string, defaults ...bool) bool

MustBool returns request form as bool with default

func (*Params) MustEscape Uses

func (p *Params) MustEscape(key string, defaults ...string) string

MustEscape returns request form as escaped string with default

func (*Params) MustFloat32 Uses

func (p *Params) MustFloat32(key string, defaults ...float32) float32

MustFloat32 returns request form as float32 with default

func (*Params) MustFloat64 Uses

func (p *Params) MustFloat64(key string, defaults ...float64) float64

MustFloat64 returns request form as float64 with default

func (*Params) MustInt Uses

func (p *Params) MustInt(key string, defaults ...int) int

MustInt returns request form as int with default

func (*Params) MustInt32 Uses

func (p *Params) MustInt32(key string, defaults ...int32) int32

MustInt32 returns request form as int32 with default

func (*Params) MustInt64 Uses

func (p *Params) MustInt64(key string, defaults ...int64) int64

MustInt64 returns request form as int64 with default

func (*Params) MustString Uses

func (p *Params) MustString(key string, defaults ...string) string

MustString returns request form as slice of string with default

func (*Params) MustStrings Uses

func (p *Params) MustStrings(key string, defaults ...[]string) []string

MustStrings returns request form as slice of string with default

func (*Params) MustUint Uses

func (p *Params) MustUint(key string, defaults ...uint) uint

MustUint returns request form as uint with default

func (*Params) MustUint32 Uses

func (p *Params) MustUint32(key string, defaults ...uint32) uint32

MustUint32 returns request form as uint32 with default

func (*Params) MustUint64 Uses

func (p *Params) MustUint64(key string, defaults ...uint64) uint64

MustUint64 returns request form as uint64 with default

func (*Params) Set Uses

func (p *Params) Set(key, value string)

Set sets key/value to params

func (*Params) SetParams Uses

func (p *Params) SetParams(params []param)

SetParams implemented Paramer

func (*Params) String Uses

func (p *Params) String(key string) (string, error)

String returns request form as string

func (*Params) Strings Uses

func (p *Params) Strings(key string) ([]string, error)

Strings returns request form as slice of string

func (*Params) Uint Uses

func (p *Params) Uint(key string) (uint, error)

Uint returns request form as uint

func (*Params) Uint32 Uses

func (p *Params) Uint32(key string) (uint32, error)

Uint32 returns request form as uint32

func (*Params) Uint64 Uses

func (p *Params) Uint64(key string) (uint64, error)

Uint64 returns request form as uint64

type Queries Uses

type Queries http.Request

Queries a new enhancement of http.Request

func (*Queries) Bool Uses

func (f *Queries) Bool(key string) (bool, error)

Bool returns request form as bool

func (*Queries) Escape Uses

func (f *Queries) Escape(key string) (string, error)

Escape returns request form as escaped string

func (*Queries) Float32 Uses

func (f *Queries) Float32(key string) (float32, error)

Float32 returns request form as float32

func (*Queries) Float64 Uses

func (f *Queries) Float64(key string) (float64, error)

Float64 returns request form as float64

func (*Queries) Int Uses

func (f *Queries) Int(key string) (int, error)

Int returns request form as int

func (*Queries) Int32 Uses

func (f *Queries) Int32(key string) (int32, error)

Int32 returns request form as int32

func (*Queries) Int64 Uses

func (f *Queries) Int64(key string) (int64, error)

Int64 returns request form as int64

func (*Queries) MustBool Uses

func (f *Queries) MustBool(key string, defaults ...bool) bool

MustBool returns request form as bool with default

func (*Queries) MustEscape Uses

func (f *Queries) MustEscape(key string, defaults ...string) string

MustEscape returns request form as escaped string with default

func (*Queries) MustFloat32 Uses

func (f *Queries) MustFloat32(key string, defaults ...float32) float32

MustFloat32 returns request form as float32 with default

func (*Queries) MustFloat64 Uses

func (f *Queries) MustFloat64(key string, defaults ...float64) float64

MustFloat64 returns request form as float64 with default

func (*Queries) MustInt Uses

func (f *Queries) MustInt(key string, defaults ...int) int

MustInt returns request form as int with default

func (*Queries) MustInt32 Uses

func (f *Queries) MustInt32(key string, defaults ...int32) int32

MustInt32 returns request form as int32 with default

func (*Queries) MustInt64 Uses

func (f *Queries) MustInt64(key string, defaults ...int64) int64

MustInt64 returns request form as int64 with default

func (*Queries) MustString Uses

func (f *Queries) MustString(key string, defaults ...string) string

MustString returns request form as string with default

func (*Queries) MustStrings Uses

func (f *Queries) MustStrings(key string, defaults ...[]string) []string

MustStrings returns request form as strings with default

func (*Queries) MustUint Uses

func (f *Queries) MustUint(key string, defaults ...uint) uint

MustUint returns request form as uint with default

func (*Queries) MustUint32 Uses

func (f *Queries) MustUint32(key string, defaults ...uint32) uint32

MustUint32 returns request form as uint32 with default

func (*Queries) MustUint64 Uses

func (f *Queries) MustUint64(key string, defaults ...uint64) uint64

MustUint64 returns request form as uint64 with default

func (*Queries) String Uses

func (f *Queries) String(key string) (string, error)

String returns request form as string

func (*Queries) Strings Uses

func (f *Queries) Strings(key string) ([]string, error)

Strings returns request form as strings

func (*Queries) Uint Uses

func (f *Queries) Uint(key string) (uint, error)

Uint returns request form as uint

func (*Queries) Uint32 Uses

func (f *Queries) Uint32(key string) (uint32, error)

Uint32 returns request form as uint32

func (*Queries) Uint64 Uses

func (f *Queries) Uint64(key string) (uint64, error)

Uint64 returns request form as uint64

func (*Queries) Values Uses

func (f *Queries) Values() url.Values

Values returns http.Request values

type ResponseTyper Uses

type ResponseTyper interface {
    ResponseType() int
}

ResponseTyper describes reponse type

type ResponseWriter Uses

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 Uses

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

Route defines HTTP route

func NewRoute Uses

func NewRoute(v interface{}, t reflect.Type,
    method reflect.Value, tp RouteType, handlers []Handler) *Route

NewRoute returns a route

func (*Route) IsStruct Uses

func (r *Route) IsStruct() bool

IsStruct returns if the execute is a struct

func (*Route) Method Uses

func (r *Route) Method() reflect.Value

Method returns finalize execute method.

func (*Route) Raw Uses

func (r *Route) Raw() interface{}

Raw returns raw data to define route.

func (*Route) RouteType Uses

func (r *Route) RouteType() RouteType

RouteType returns route type.

type RouteType Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (s *StaticOptions) IsFilterExt(rPath string) bool

IsFilterExt decribes if rPath's ext match filter ext

type StatusResult Uses

type StatusResult struct {
    Code   int
    Result interface{}
}

StatusResult describes http response

type Tango Uses

type Tango struct {
    http.Server
    Router

    ErrHandler Handler
    // contains filtered or unexported fields
}

Tango describes tango object

func Classic Uses

func Classic(l ...Logger) *Tango

Classic returns the tango with default handlers and logger

func New Uses

func New(handlers ...Handler) *Tango

New creates tango with the default logger and handlers

func NewWithLog Uses

func NewWithLog(logger Logger, handlers ...Handler) *Tango

NewWithLog creates tango with the special logger and handlers

func (*Tango) Any Uses

func (t *Tango) Any(url string, c interface{}, middlewares ...Handler)

Any sets a route every support method is OK.

func (*Tango) Delete Uses

func (t *Tango) Delete(url string, c interface{}, middlewares ...Handler)

Delete sets a route with DELETE method

func (*Tango) Get Uses

func (t *Tango) Get(url string, c interface{}, middlewares ...Handler)

Get sets a route with GET method

func (*Tango) Group Uses

func (t *Tango) Group(p string, o interface{}, handlers ...Handler)

Group adds routines groups

func (*Tango) Head Uses

func (t *Tango) Head(url string, c interface{}, middlewares ...Handler)

Head sets a route with HEAD method

func (*Tango) Logger Uses

func (t *Tango) Logger() Logger

Logger returns logger interface

func (*Tango) Options Uses

func (t *Tango) Options(url string, c interface{}, middlewares ...Handler)

Options sets a route with OPTIONS method

func (*Tango) Patch Uses

func (t *Tango) Patch(url string, c interface{}, middlewares ...Handler)

Patch sets a route with PATCH method

func (*Tango) Post Uses

func (t *Tango) Post(url string, c interface{}, middlewares ...Handler)

Post sets a route with POST method

func (*Tango) Put Uses

func (t *Tango) Put(url string, c interface{}, middlewares ...Handler)

Put sets a route with PUT method

func (*Tango) Run Uses

func (t *Tango) Run(args ...interface{})

Run the http server. Listening on os.GetEnv("PORT") or 8000 by default.

func (*Tango) RunTLS Uses

func (t *Tango) RunTLS(certFile, keyFile string, args ...interface{})

RunTLS runs the https server with special cert and key files

func (*Tango) ServeHTTP Uses

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) Trace Uses

func (t *Tango) Trace(url string, c interface{}, middlewares ...Handler)

Trace sets a route with TRACE method

func (*Tango) Use Uses

func (t *Tango) Use(handlers ...Handler)

Use addes some global handlers

func (*Tango) UseHandler Uses

func (t *Tango) UseHandler(handler http.Handler)

UseHandler adds a standard http handler to tango's

type XML Uses

type XML struct{}

XML descirbes return XML type

func (XML) ResponseType Uses

func (XML) ResponseType() int

ResponseType implementes ResponseTyper

type XMLError Uses

type XMLError struct {
    XMLName xml.Name `xml:"err"`
    Content string   `xml:"content"`
}

XMLError describes return xml error

type XMLString Uses

type XMLString struct {
    XMLName xml.Name `xml:"string"`
    Content string   `xml:"content"`
}

XMLString describes return xml string

type Xml Uses

type Xml struct{}

Xml descirbes return XML type Deprecated: use XML instead

func (Xml) ResponseType Uses

func (Xml) ResponseType() int

ResponseType implementes ResponseTyper

Package tango imports 29 packages (graph) and is imported by 12 packages. Updated 2019-11-13. Refresh now. Tools for package owners.