Documentation
¶
Index ¶
- type Context
- func (c *Context) Data(code int, data []byte)
- func (c *Context) Fail(code int, err string)
- func (c *Context) HTML(code int, name string, data interface{})
- func (c *Context) JSON(code int, obj interface{})
- func (c *Context) Next()
- func (c *Context) Param(key string) string
- func (c *Context) PostForm(key string) string
- func (c *Context) Query(key string) string
- func (c *Context) SetHeader(key string, value string)
- func (c *Context) Status(code int)
- func (c *Context) String(code int, format string, values ...interface{})
- type Engine
- type H
- type HandleFunc
- type RouterGroup
- func (group *RouterGroup) GET(relativePath string, handle HandleFunc)
- func (group *RouterGroup) Group(prefix string) *RouterGroup
- func (group *RouterGroup) POST(relativePath string, handle HandleFunc)
- func (group *RouterGroup) Static(relativePath string, root string)
- func (group *RouterGroup) Use(middlewares ...HandleFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { // origin objects Writer http.ResponseWriter Req *http.Request // request info Path string Method string Params map[string]string // response info StatusCode int // contains filtered or unexported fields }
Context is the encapsulation of http.ResponseWriter and *http.Request
type Engine ¶
type Engine struct { *RouterGroup // contains filtered or unexported fields }
Engine implement the interface of ServeHTTP
func (*Engine) LoadHTMLGlob ¶
LoadHTMLGlob loads a html template
func (*Engine) ServeHTTP ¶
func (engine *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implement the interface of http.Handler
func (*Engine) SetFuncMap ¶
SetFuncMap sets the funcMap for template
type HandleFunc ¶
type HandleFunc func(c *Context)
HandleFunc defines the request handler used by gsg
func Logger ¶
func Logger() HandleFunc
func Recovery ¶
func Recovery() HandleFunc
Recovery returns a middleware that recovers from any panics and writes a 500 if there was one.
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
RouterGroup is a group of router
func (*RouterGroup) GET ¶
func (group *RouterGroup) GET(relativePath string, handle HandleFunc)
GET defines the method to add GET request
func (*RouterGroup) Group ¶
func (group *RouterGroup) Group(prefix string) *RouterGroup
Group is defined to create a new RouterGroup remember all groups share the same Engine instance
func (*RouterGroup) POST ¶
func (group *RouterGroup) POST(relativePath string, handle HandleFunc)
POST defines the method to add POST request
func (*RouterGroup) Static ¶
func (group *RouterGroup) Static(relativePath string, root string)
Static serve static files
func (*RouterGroup) Use ¶
func (group *RouterGroup) Use(middlewares ...HandleFunc)
Click to show internal directories.
Click to hide internal directories.