Documentation
¶
Index ¶
- Constants
- func AssetHandler(prefix string, assets *embed.FS, root string) http.Handler
- type Context
- func (c *Context) Abort()
- func (c *Context) CJson(data interface{})
- func (c *Context) CResponse(data string)
- func (c *Context) GetCookie(name string) (string, error)
- func (c *Context) GetFile(key string) (*FormFile, error)
- func (c *Context) GetHeaderBool(key string) bool
- func (c *Context) GetHeaderFloat(key string) float64
- func (c *Context) GetHeaderInt(key string) int
- func (c *Context) GetHeaderInt64(key string) int64
- func (c *Context) GetHeaderString(key string) string
- func (c *Context) GetParam(name string) string
- func (c *Context) GetPostBool(key string) bool
- func (c *Context) GetPostFloat64(key string) float64
- func (c *Context) GetPostFrom() url.Values
- func (c *Context) GetPostInt(key string) int
- func (c *Context) GetPostInt64(key string) int64
- func (c *Context) GetPostJson() (map[string]interface{}, error)
- func (c *Context) GetPostJsonParse(parse interface{}) error
- func (c *Context) GetPostString(key string) (s string)
- func (c *Context) GetQueryBool(key string) bool
- func (c *Context) GetQueryFloat(key string) float64
- func (c *Context) GetQueryInt(key string) int
- func (c *Context) GetQueryInt64(key string) int64
- func (c *Context) GetQueryString(key string) string
- func (c *Context) GetResponseKeyCode() string
- func (c *Context) GetResponseKeyData() string
- func (c *Context) GetResponseKeyMessage() string
- func (c *Context) GetUrlParam() string
- func (c *Context) IsAborted() bool
- func (c *Context) JsonGzipResponse(code int, message string, data interface{})
- func (c *Context) JsonResponse(code int, message string, data interface{})
- func (c *Context) JsonTrackResponse(code int, message string, data interface{})
- func (c *Context) Next()
- func (c *Context) SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool)
- func (c *Context) Template(data interface{}, temp string)
- func (c *Context) TemplateMultiple(data interface{}, temps []string)
- type Engine
- func (engine *Engine) IsDebug(isDebug bool)
- func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (engine *Engine) SetResponseKeyCode(codeKey string)
- func (engine *Engine) SetResponseKeyData(dataKey string)
- func (engine *Engine) SetResponseKeyMessage(messageKey string)
- func (engine *Engine) SetTemplate(templateDir, templateSuffix string)
- type FilesFilesyste
- type FormFile
- type HandlersChain
- type HttpFunc
- type ResponseWriter
- type Router
- func (r *Router) AttachFs(relativePath string, root string)
- func (r *Router) CreateRouter()
- func (r *Router) Get(path string, handler ...HttpFunc)
- func (r *Router) GetHandler(path string, handler ...HttpFunc)
- func (r *Router) Group(path string, handlers ...HttpFunc) *Router
- func (r *Router) Post(path string, handler ...HttpFunc)
- func (r *Router) StaticFS(relativePath string, publicAsset *embed.FS, root string)
- func (r *Router) UseMiddleware(handler ...HttpFunc)
- type RouterInfo
- type RouterNode
- type RouterParam
- type RouterParams
- type RouterTree
- type RouterTrees
Constants ¶
View Source
const ( POST = "POST" GET = "GET" PUT = "PUT" WS = "WS" )
View Source
const ( //表单提交时去 header需带参数 //HEADER_REQUEST_TOKEN = "requestToken" DEFAULT_SERVER_NAME = "Hmm Server 2.0.0" DEFAULT_TEMPLATE_DIR = "/Asset/Template" DEFAULT_TEMPLATE_SUFIXX = ".html" DEFAULT_JSON_KEY_CODE = "code" DEFAULT_JSON_KEY_MSG = "message" DEFAULT_JSON_KEY_DATA = "data" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct { RouterNode *RouterNode Request *http.Request Writer ResponseWriter // contains filtered or unexported fields }
func (*Context) GetHeaderBool ¶
func (*Context) GetHeaderFloat ¶
func (*Context) GetHeaderInt ¶
func (*Context) GetHeaderInt64 ¶
func (*Context) GetHeaderString ¶
func (*Context) GetPostBool ¶
func (*Context) GetPostFloat64 ¶
func (*Context) GetPostFrom ¶
func (*Context) GetPostInt ¶
func (*Context) GetPostInt64 ¶ added in v1.1.9
func (*Context) GetPostJson ¶
func (*Context) GetPostJsonParse ¶
func (*Context) GetPostString ¶
func (*Context) GetQueryBool ¶
func (*Context) GetQueryFloat ¶
func (*Context) GetQueryInt ¶
func (*Context) GetQueryInt64 ¶
func (*Context) GetQueryString ¶
func (*Context) GetResponseKeyCode ¶ added in v1.2.11
func (*Context) GetResponseKeyData ¶ added in v1.2.11
func (*Context) GetResponseKeyMessage ¶ added in v1.2.11
func (*Context) GetUrlParam ¶ added in v1.1.6
func (*Context) JsonGzipResponse ¶
func (*Context) JsonResponse ¶
func (*Context) JsonTrackResponse ¶
func (*Context) SetCookie ¶ added in v1.1.8
func (c *Context) SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool)
* maxAge: 过期时间.如果只想设置 Cookie 的保存路径而不想设置存活时间,可以在第三个 参数中传递 nil ; path: cookie 的路径 ; domain: cookie 的路径 Domain 作用域 本地调试配置成 localhost , 正式上线配置成域名 ; secure: 当 secure 值为 true 时,cookie 在 HTTP 中是无效,在 HTTPS 中 才有效 ; httpOnly: 微软对 COOKIE 做的扩展。如果在 COOKIE 中设置了“httpOnly”属性, 则通过程序(JS 脚本、applet 等)将无法读取到 COOKIE 信息,防止 XSS 攻击产生; *
func (*Context) TemplateMultiple ¶
* 多模板解析
type Engine ¶
type Engine struct { Router // contains filtered or unexported fields }
func (*Engine) ServeHTTP ¶
func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request)
func (*Engine) SetResponseKeyCode ¶
func (*Engine) SetResponseKeyData ¶
func (*Engine) SetResponseKeyMessage ¶
func (*Engine) SetTemplate ¶
type FilesFilesyste ¶
type FilesFilesyste struct {
// contains filtered or unexported fields
}
type HandlersChain ¶
type HandlersChain []HttpFunc
type ResponseWriter ¶
type ResponseWriter struct { http.ResponseWriter Body *bytes.Buffer }
* context中的响应数据
type Router ¶
type Router struct { Handlers HandlersChain // contains filtered or unexported fields }
func (*Router) CreateRouter ¶
func (r *Router) CreateRouter()
func (*Router) GetHandler ¶
func (*Router) UseMiddleware ¶
type RouterInfo ¶
type RouterInfo struct {
// contains filtered or unexported fields
}
type RouterNode ¶
type RouterNode struct {
// contains filtered or unexported fields
}
type RouterParam ¶ added in v1.2.10
type RouterParams ¶ added in v1.2.10
type RouterParams []RouterParam
func (RouterParams) ByName ¶ added in v1.2.10
func (ps RouterParams) ByName(name string) (va string)
ByName returns the value of the first Param which key matches the given name. If no matching Param is found, an empty string is returned.
type RouterTree ¶
type RouterTree struct {
// contains filtered or unexported fields
}
type RouterTrees ¶
type RouterTrees []RouterTree
Source Files
¶
Click to show internal directories.
Click to hide internal directories.