Documentation
¶
Index ¶
- Constants
- func Author(engine *Engine, addr string)
- func SetDebugMode(mode bool)
- func SetTimeOut(read time.Duration, write time.Duration)
- func Try(fun func(), handler func(interface{}))
- type Context
- func (c *Context) Abort()
- func (c *Context) AllForm() map[string]string
- func (c *Context) AllParam() map[string]string
- func (c *Context) AllQuery() map[string]string
- func (c *Context) BindAll(obj interface{}) error
- func (c *Context) BindForm(obj interface{}) error
- func (c *Context) BindJson(obj interface{}) error
- func (c *Context) BindParam(obj interface{}) error
- func (c *Context) BindQuery(obj interface{}) error
- func (c *Context) Body() string
- func (c *Context) ClientIP(useProxy bool) string
- func (c *Context) Data(code int, data []byte)
- func (c *Context) DefaultForm(key, defaultValue string) string
- func (c *Context) DefaultParam(key, defaultValue string) string
- func (c *Context) DefaultQuery(key, defaultValue string) string
- func (c *Context) Fail(code int, err string)
- func (c *Context) Form(key string) string
- func (c *Context) FormFile(name string) (*multipart.FileHeader, error)
- func (c *Context) Get(key string) (value interface{}, exists bool)
- func (c *Context) GetBool(key string) (b bool)
- func (c *Context) GetDuration(key string) (d time.Duration)
- func (c *Context) GetFloat64(key string) (f64 float64)
- func (c *Context) GetInt(key string) (i int)
- func (c *Context) GetInt64(key string) (i64 int64)
- func (c *Context) GetString(key string) (s string)
- func (c *Context) GetStringMap(key string) (sm map[string]interface{})
- func (c *Context) GetStringMapString(key string) (sms map[string]string)
- func (c *Context) GetStringMapStringSlice(key string) (temp map[string][]string)
- func (c *Context) GetStringSlice(key string) (ss []string)
- func (c *Context) GetTime(key string) (t time.Time)
- func (c *Context) GetUint(key string) (ui uint)
- func (c *Context) GetUint64(key string) (ui64 uint64)
- func (c *Context) HTML(code int, name string, data interface{})
- func (c *Context) HttpProxy(uri string, logger *log.Logger, ...) (err error)
- func (c *Context) IsAborted() bool
- func (c *Context) JSON(code int, obj interface{})
- func (c *Context) MultipartForm() (*multipart.Form, error)
- func (c *Context) Next()
- func (c *Context) Param(key string) string
- func (c *Context) Proxy(uri string, logger *log.Logger, ...) error
- func (c *Context) Query(key string) string
- func (c *Context) Redirect(code int, location string)
- func (c *Context) SaveUploadedFile(file *multipart.FileHeader, dst string) error
- func (c *Context) Set(key string, value interface{})
- func (c *Context) SetHeader(key string, value string)
- func (c *Context) SetStatus(code int)
- func (c *Context) String(code int, format string, values ...interface{})
- func (c *Context) WebSocketProxy(uri string, logger *log.Logger, ...) (err error)
- type Engine
- func (engine *Engine) LoadHtmlGlob(pattern string)
- func (engine *Engine) Run(addr string) (err error)
- func (engine *Engine) RunTLS(addr string, certFile string, keyFile string) (err error)
- func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (engine *Engine) SetFuncMap(funcMap template.FuncMap)
- type ErrorHandel
- type H
- type HandlerFunc
- type LimitRate
- type RouterGroup
- func (group *RouterGroup) ANY(pattern string, handler HandlerFunc)
- func (group *RouterGroup) DELETE(pattern string, handler HandlerFunc)
- func (group *RouterGroup) GET(pattern string, handler HandlerFunc)
- func (group *RouterGroup) Group(prefix string) *RouterGroup
- func (group *RouterGroup) HEAD(pattern string, handler HandlerFunc)
- func (group *RouterGroup) OPTIONS(pattern string, handler HandlerFunc)
- func (group *RouterGroup) PATCH(pattern string, handler HandlerFunc)
- func (group *RouterGroup) POST(pattern string, handler HandlerFunc)
- func (group *RouterGroup) PROXY(pattern string, uri string, logger *log.Logger, ...)
- func (group *RouterGroup) PUT(pattern string, handler HandlerFunc)
- func (group *RouterGroup) SetErrorHandle(handle *ErrorHandel)
- func (group *RouterGroup) Static(relativePath string, root string)
- func (group *RouterGroup) TRACE(pattern string, handler HandlerFunc)
- func (group *RouterGroup) Use(middlewares ...HandlerFunc)
Constants ¶
View Source
const ( FrameWorkVersion = "1.0.0" //框架版本 MessageNotFound = "404 Not Found" //默认资源不存在消息 MessageInternalServerError = "Internal Server Error" //默认错误消息 )
View Source
const ( ContentTypeJson = "application/json;charset=utf-8;" //返回json的头 ContentTypeText = "text/plain;charset=utf-8;" //返回字符的头 ContentTypeHtml = "text/html;charset=utf-8;" //返回html的头 HeaderLocation = "Location" //重定向跳转 )
View Source
const ( BindFormTagName = "form" //表单绑定参数tag名称 BindDefaultValueTagName = "default" //表单绑定默认值tag名称 )
View Source
const (
ContentType = "Content-Type" //主体类型
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct { Writer http.ResponseWriter Request *http.Request Path string Method string Params map[string]string StatusCode int Keys map[string]interface{} // contains filtered or unexported fields }
Context 上下文结构体
func (*Context) DefaultForm ¶
DefaultForm 获取单个post参数,不存在则返回默认参数
func (*Context) DefaultParam ¶
DefaultParam 获取路径参数,不存在返回默认参数
func (*Context) DefaultQuery ¶
DefaultQuery 获取单个get参数,不存在则返回默认值
func (*Context) FormFile ¶
func (c *Context) FormFile(name string) (*multipart.FileHeader, error)
FormFile 获取上传文件
func (*Context) GetFloat64 ¶
func (*Context) GetStringMap ¶
func (*Context) GetStringMapString ¶
func (*Context) GetStringMapStringSlice ¶
func (*Context) GetStringSlice ¶
func (*Context) HttpProxy ¶
func (c *Context) HttpProxy(uri string, logger *log.Logger, filter func(r *http.Request, w http.ResponseWriter, proxy *httputil.ReverseProxy), errorHandle func(http.ResponseWriter, *http.Request, error)) (err error)
HttpProxy http反向代理
func (*Context) MultipartForm ¶
MultipartForm 多文件上传
func (*Context) Proxy ¶
func (c *Context) Proxy(uri string, logger *log.Logger, filter func(r *http.Request, w http.ResponseWriter, proxy *httputil.ReverseProxy), errorHandle func(http.ResponseWriter, *http.Request, error)) error
Proxy 通用反向代理
func (*Context) SaveUploadedFile ¶
func (c *Context) SaveUploadedFile(file *multipart.FileHeader, dst string) error
SaveUploadedFile 保存上传文件
type Engine ¶
type Engine struct { *RouterGroup MaxMultipartMemory int64 // contains filtered or unexported fields }
func (*Engine) LoadHtmlGlob ¶
func (*Engine) ServeHTTP ¶
func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request)
func (*Engine) SetFuncMap ¶
type ErrorHandel ¶
type HandlerFunc ¶
type HandlerFunc func(*Context)
type LimitRate ¶
type LimitRate struct {
// contains filtered or unexported fields
}
func GetLimitRateIns ¶
func NewLimitRate ¶
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
func (*RouterGroup) ANY ¶
func (group *RouterGroup) ANY(pattern string, handler HandlerFunc)
func (*RouterGroup) DELETE ¶
func (group *RouterGroup) DELETE(pattern string, handler HandlerFunc)
func (*RouterGroup) GET ¶
func (group *RouterGroup) GET(pattern string, handler HandlerFunc)
func (*RouterGroup) Group ¶
func (group *RouterGroup) Group(prefix string) *RouterGroup
func (*RouterGroup) HEAD ¶
func (group *RouterGroup) HEAD(pattern string, handler HandlerFunc)
func (*RouterGroup) OPTIONS ¶
func (group *RouterGroup) OPTIONS(pattern string, handler HandlerFunc)
func (*RouterGroup) PATCH ¶
func (group *RouterGroup) PATCH(pattern string, handler HandlerFunc)
func (*RouterGroup) POST ¶
func (group *RouterGroup) POST(pattern string, handler HandlerFunc)
func (*RouterGroup) PROXY ¶
func (group *RouterGroup) PROXY(pattern string, uri string, logger *log.Logger, filter func(r *http.Request, w http.ResponseWriter, proxy *httputil.ReverseProxy), errorHandle func(http.ResponseWriter, *http.Request, error))
func (*RouterGroup) PUT ¶
func (group *RouterGroup) PUT(pattern string, handler HandlerFunc)
func (*RouterGroup) SetErrorHandle ¶
func (group *RouterGroup) SetErrorHandle(handle *ErrorHandel)
func (*RouterGroup) Static ¶
func (group *RouterGroup) Static(relativePath string, root string)
func (*RouterGroup) TRACE ¶
func (group *RouterGroup) TRACE(pattern string, handler HandlerFunc)
func (*RouterGroup) Use ¶
func (group *RouterGroup) Use(middlewares ...HandlerFunc)
Click to show internal directories.
Click to hide internal directories.