Documentation ¶
Index ¶
- func NotFoundHandler(c *Context) (err error)
- type Context
- func (c *Context) AddHeader(key, value string)
- func (c *Context) Attachment(file, name string) error
- func (c *Context) Blob(code int, contentType string, b []byte) (err error)
- func (c *Context) Context() context.Context
- func (c *Context) Cookie(name string) (*http.Cookie, error)
- func (c *Context) CookieValue(n string) string
- func (c *Context) Cookies() []*http.Cookie
- func (c *Context) Error(code int, msg string) (err error)
- func (c *Context) ErrorString(err error) (errStr string)
- func (c *Context) File(file string) (err error)
- func (c *Context) FormFile(name string) (*multipart.FileHeader, error)
- func (c *Context) FormParams() (url.Values, error)
- func (c *Context) FormValue(name string) string
- func (c *Context) GetQueryArray(name string) ([]string, bool)
- func (c *Context) GetQueryParam(name string) (string, bool)
- func (c *Context) Header(name string) string
- func (c *Context) Inline(file, name string) error
- func (c *Context) IsWebsocket() bool
- func (c *Context) JSON(code int, i interface{}) error
- func (c *Context) JSONBlob(code int, b []byte) (err error)
- func (c *Context) JSONPretty(code int, i interface{}, indent string) (err error)
- func (c *Context) Json(code int, i interface{}) (errStr string)
- func (c *Context) JsonBlob(code int, s string) (errStr string)
- func (c *Context) MultipartForm() (*multipart.Form, error)
- func (c *Context) Param(name string) string
- func (c *Context) QueryParam(name string) string
- func (c *Context) QueryParams() url.Values
- func (c *Context) QueryString() string
- func (c *Context) ReadAndValidate(vals interface{}) (status int, err error)
- func (c *Context) ReadAndValidateJSON(res interface{}, dumper ...io.Writer) (code int, err error)
- func (c *Context) ReadBody() (body string, errStr string)
- func (c *Context) ReadJSON(res interface{}, dumper ...io.Writer) (code int, err error)
- func (c *Context) ReadJSONBody() (body interface{}, errStr string)
- func (c *Context) ReadParams(vals interface{}) (status int, err error)
- func (c *Context) Redirect(code int, url string) error
- func (c *Context) RemoteAddr() string
- func (c *Context) Request() *http.Request
- func (c *Context) Response() http.ResponseWriter
- func (c *Context) ResponseJSONEncoder() *json.Encoder
- func (c *Context) SSEvent(name string, message interface{})
- func (c *Context) SetCookie(cookie *http.Cookie)
- func (c *Context) SetHeader(key, value string)
- func (c *Context) Stream(code int, contentType string, r io.Reader) (err error)
- func (c *Context) String(code int, s string) error
- func (c *Context) StringBlob(code int, ct string, s string) (errStr string)
- func (c *Context) Write(b []byte) (int, error)
- func (c *Context) WriteChunk(s string) (bytesWriten int, errStr string)
- func (c *Context) WriteHeader(statusCode int, contentType ...string)
- type ContextHandlerFunc
- type Handler
- type HandlerFunc
- type MiniGin
- type RouterGroup
- func (g *RouterGroup) DELETE(path string, h func(c *Context))
- func (g *RouterGroup) Delete(path string, h http.HandlerFunc)
- func (g *RouterGroup) GET(pattern string, h func(c *Context))
- func (g *RouterGroup) Get(pattern string, h http.HandlerFunc)
- func (g *RouterGroup) Group(relPath string) *RouterGroup
- func (g *RouterGroup) HEAD(path string, h func(c *Context))
- func (g *RouterGroup) Head(path string, h http.HandlerFunc)
- func (g *RouterGroup) OPTIONS(path string, h func(c *Context))
- func (g *RouterGroup) Options(path string, h http.HandlerFunc)
- func (g *RouterGroup) PATCH(path string, h func(c *Context))
- func (g *RouterGroup) POST(path string, h func(c *Context))
- func (g *RouterGroup) PUT(path string, h func(c *Context))
- func (g *RouterGroup) Patch(path string, h http.HandlerFunc)
- func (g *RouterGroup) Post(path string, h http.HandlerFunc)
- func (g *RouterGroup) Put(path string, h http.HandlerFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NotFoundHandler ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func NewHttpContext ¶
func NewHttpContext(w http.ResponseWriter, r *http.Request) *Context
func (*Context) Attachment ¶
func (*Context) CookieValue ¶
func (*Context) ErrorString ¶ added in v0.2.2
func (*Context) IsWebsocket ¶ added in v0.1.2
func (*Context) JSONPretty ¶
func (*Context) QueryParam ¶
func (*Context) QueryParams ¶
func (*Context) QueryString ¶
func (*Context) ReadAndValidate ¶
read values from path, query string, form, header or cookie, store them in a struct specified by vals, then values are validated by using "github.com/go-playground/validator/v10". param name is specified by field tag. e.g.
var vals struct { V1 int `path:"v1" validate:"gt=0"` // read path param "v1", the value must be greater than 0 V2 bool `query:"v2"` // read query param "v2=xxx" V3 string `form:"v3" validate:"required"` // read form param "v3=xxx", V4 int `header:"Content-Length"` // read header "Content-Length" V5 []byte `cookie:"v5"` // read cookie "v4" }
if status, err := c.ReadAndValidate(&vals); err != nil { c.Error(status, err.Error()) return }
func (*Context) ReadAndValidateJSON ¶
func (*Context) ReadJSONBody ¶ added in v0.2.2
func (*Context) ReadParams ¶
read values from path, query string, form, header or cookie, store them in a struct specified by vals. param name is specified by field tag. e.g.
var vals struct { V1 int `path:"v1" optional` // read path param "v1" optionally, any integer type (u)int8/16/32/64 is acceptable V2 bool `query:"v2" ignore-error` // read query param "v2=xxx", ignore error occurring V3 string `form:"v3"` // read form param "v3=xxx", type string can be replace with []byte V4 int `header:"Content-Length"` // read header "Content-Length" V5 []byte `cookie:"v5" optional` // read cookie "v4" opiontally }
if status, err := c.ReadParams(&vals); err != nil { c.Error(status, err.Error()) return }
func (*Context) RemoteAddr ¶ added in v0.1.7
func (*Context) Response ¶
func (c *Context) Response() http.ResponseWriter
func (*Context) ResponseJSONEncoder ¶ added in v0.2.3
func (*Context) StringBlob ¶ added in v0.2.2
func (*Context) WriteChunk ¶ added in v0.2.3
func (*Context) WriteHeader ¶ added in v0.2.3
type ContextHandlerFunc ¶
type ContextHandlerFunc func(c *Context)
type Handler ¶
type negroni.Handler interface { ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) }
func CreateBodyDumpingHandler ¶ added in v0.2.0
func WithLogger ¶
func WrapFunc ¶ added in v0.1.1
func WrapFunc(handlerFunc http.HandlerFunc) Handler
func WrapMiddleFunc ¶ added in v0.1.1
func WrapMiddleFunc(handlerFunc HandlerFunc) Handler
type HandlerFunc ¶
type HandlerFunc = negroni.HandlerFunc
type HandlerFunc func(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
type MiniGin ¶
type MiniGin struct { RouterGroup // contains filtered or unexported fields }
func (*MiniGin) NotFoundHandler ¶
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
func (*RouterGroup) DELETE ¶
func (g *RouterGroup) DELETE(path string, h func(c *Context))
func (*RouterGroup) Delete ¶
func (g *RouterGroup) Delete(path string, h http.HandlerFunc)
func (*RouterGroup) GET ¶
func (g *RouterGroup) GET(pattern string, h func(c *Context))
------ context -----
func (*RouterGroup) Get ¶
func (g *RouterGroup) Get(pattern string, h http.HandlerFunc)
func (*RouterGroup) Group ¶
func (g *RouterGroup) Group(relPath string) *RouterGroup
func (*RouterGroup) HEAD ¶
func (g *RouterGroup) HEAD(path string, h func(c *Context))
func (*RouterGroup) Head ¶
func (g *RouterGroup) Head(path string, h http.HandlerFunc)
func (*RouterGroup) OPTIONS ¶
func (g *RouterGroup) OPTIONS(path string, h func(c *Context))
func (*RouterGroup) Options ¶
func (g *RouterGroup) Options(path string, h http.HandlerFunc)
func (*RouterGroup) PATCH ¶
func (g *RouterGroup) PATCH(path string, h func(c *Context))
func (*RouterGroup) POST ¶
func (g *RouterGroup) POST(path string, h func(c *Context))
func (*RouterGroup) PUT ¶
func (g *RouterGroup) PUT(path string, h func(c *Context))
func (*RouterGroup) Patch ¶
func (g *RouterGroup) Patch(path string, h http.HandlerFunc)
func (*RouterGroup) Post ¶
func (g *RouterGroup) Post(path string, h http.HandlerFunc)
func (*RouterGroup) Put ¶
func (g *RouterGroup) Put(path string, h http.HandlerFunc)
----- HandlerFunc ----
Click to show internal directories.
Click to hide internal directories.