Documentation
¶
Index ¶
- func NewResponse(w http.ResponseWriter) http.ResponseWriter
- type Context
- func (ctx *Context) Abort()
- func (ctx *Context) AutoError(data interface{})
- func (ctx *Context) BadRequest(data interface{})
- func (ctx *Context) Bind(data interface{}) error
- func (ctx *Context) ClientIP() string
- func (ctx *Context) Conflict(data interface{})
- func (ctx *Context) Data(code int, data []byte)
- func (ctx *Context) DumpRequest() ([]byte, error)
- func (ctx *Context) Forbidden(data interface{})
- func (ctx *Context) GetFormFile(key string) (*FormFile, error)
- func (ctx *Context) GetKey(key string) interface{}
- func (ctx *Context) Gone(data interface{})
- func (ctx *Context) HTML(code int, data string)
- func (ctx *Context) InternalServerError(data interface{})
- func (ctx *Context) JSON(code int, data interface{})
- func (ctx *Context) Locked(data interface{})
- func (ctx *Context) MatchedHandlers() []HandleFunc
- func (ctx *Context) NotFound(data interface{})
- func (ctx *Context) PaymentRequired(data interface{})
- func (ctx *Context) Redirect(url string, code int)
- func (ctx *Context) SetKey(key string, val interface{})
- func (ctx *Context) ShowError(code int, data interface{})
- func (ctx *Context) StartAt() time.Time
- func (ctx *Context) Status(code int)
- func (ctx *Context) Text(code int, data string)
- func (ctx *Context) TooManyRequests(data interface{})
- func (ctx *Context) Unauthorized(data interface{})
- type FileRoute
- type FormFile
- type HTTPError
- type HandleFunc
- type Mux
- func (m *Mux) ANY(pattern string, hs ...HandleFunc)
- func (m *Mux) AddFileRoute(uri, httpdir string)
- func (m *Mux) AddRoute(method, pattern string, handlers []HandleFunc)
- func (m *Mux) AllFileRoutes() []*FileRoute
- func (m *Mux) AllRoutes() []*Route
- func (m *Mux) DELETE(pattern string, hs ...HandleFunc)
- func (m *Mux) DelGlobalPostMidware(h HandleFunc)
- func (m *Mux) DelGlobalPreMidware(h HandleFunc)
- func (m *Mux) FILE(uri, httpdir string)
- func (m *Mux) GET(pattern string, hs ...HandleFunc)
- func (m *Mux) HEAD(pattern string, hs ...HandleFunc)
- func (m *Mux) OPTIONS(pattern string, hs ...HandleFunc)
- func (m *Mux) PATCH(pattern string, hs ...HandleFunc)
- func (m *Mux) POST(pattern string, hs ...HandleFunc)
- func (m *Mux) PUT(pattern string, hs ...HandleFunc)
- func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (m *Mux) SetAuditLog(h HandleFunc)
- func (m *Mux) SetCatchPanic(h HandleFunc)
- func (m *Mux) SetDebug(flag bool)
- func (m *Mux) SetGlobalPostMidware(h HandleFunc)
- func (m *Mux) SetGlobalPreMidware(h HandleFunc)
- func (m *Mux) SetNotFound(h HandleFunc)
- type Params
- type Response
- func (r *Response) CloseNotify() <-chan bool
- func (r *Response) ErrMsg() string
- func (r *Response) Flush()
- func (r *Response) Header() http.Header
- func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (r *Response) Size() int64
- func (r *Response) StatusCode() int
- func (r *Response) Write(bs []byte) (n int, err error)
- func (r *Response) WriteHeader(code int)
- type Route
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewResponse ¶
func NewResponse(w http.ResponseWriter) http.ResponseWriter
NewResponse is exported
Types ¶
type Context ¶
type Context struct { Req *http.Request // raw http request Res http.ResponseWriter // raw http response writer Query Params // query params + post forms + multipart form values Path Params // path params FormFiles map[string][]*multipart.FileHeader // form files // contains filtered or unexported fields }
Context for request scope
func (*Context) GetFormFile ¶
GetFormFile is exported
func (*Context) InternalServerError ¶
func (ctx *Context) InternalServerError(data interface{})
InternalServerError ...
func (*Context) MatchedHandlers ¶
func (ctx *Context) MatchedHandlers() []HandleFunc
MatchedHandlers ...
func (*Context) PaymentRequired ¶
func (ctx *Context) PaymentRequired(data interface{})
PaymentRequired ...
func (*Context) TooManyRequests ¶
func (ctx *Context) TooManyRequests(data interface{})
TooManyRequests ...
type FileRoute ¶
type FileRoute struct { FullPath string // request full path (with prefix) HTTPDir string // local http dir path }
FileRoute represents single user defined httpdir files route to serving static files
type FormFile ¶
type FormFile struct { Keyname string `json:"keyname"` Filename string `json:"filename"` Size int64 `json:"size"` Headers map[string][]string `json:"headers"` Bytes []byte `json:"bytes"` }
FormFile is an parsed & loaded MultipartForm.File
type HTTPError ¶
type HTTPError struct {
Error interface{} `json:"error"`
}
HTTPError is an internal http error body
type Mux ¶
type Mux struct { sync.RWMutex // protect Routes & FileRoutes Routes []*Route // all http routes FileRoutes []*FileRoute // all httpdir file routes PreMidwares []HandleFunc // pre global midwares PostMidwares []HandleFunc // post global midwares triggered afterwards NotFound HandleFunc // not found handler CatchPanic HandleFunc // panic handler AuditLog HandleFunc // audit handler // contains filtered or unexported fields }
Mux is a minimal http router implement
func (*Mux) AddRoute ¶
func (m *Mux) AddRoute(method, pattern string, handlers []HandleFunc)
AddRoute ...
func (*Mux) DelGlobalPostMidware ¶
func (m *Mux) DelGlobalPostMidware(h HandleFunc)
DelGlobalPostMidware ...
func (*Mux) DelGlobalPreMidware ¶
func (m *Mux) DelGlobalPreMidware(h HandleFunc)
DelGlobalPreMidware ...
func (*Mux) OPTIONS ¶
func (m *Mux) OPTIONS(pattern string, hs ...HandleFunc)
OPTIONS is exported ...
func (*Mux) ServeHTTP ¶
func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implement http.Handler
func (*Mux) SetGlobalPostMidware ¶
func (m *Mux) SetGlobalPostMidware(h HandleFunc)
SetGlobalPostMidware ...
func (*Mux) SetGlobalPreMidware ¶
func (m *Mux) SetGlobalPreMidware(h HandleFunc)
SetGlobalPreMidware ...
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response re-implement the http.ResponseWriter by rewrap an exists http.ResponseWriter thus to obtain the code / body size replied to the client See: https://golang.org/pkg/net/http/#ResponseWriter
func (*Response) WriteHeader ¶
WriteHeader re-implement http.ResponseWriter