Documentation ¶
Index ¶
- func Recovery(ctx *Context)
- type Account
- type Context
- func (c *Context) Abort()
- func (c *Context) BindJSON(obj any) error
- func (c *Context) BindXML(obj any) error
- func (c *Context) Data(code int, data []byte) error
- func (c *Context) File(code int, filepath string)
- func (c *Context) FileAttachment(code int, filename string, filepath string)
- func (c *Context) FileFromFS(code int, filepath string, fs http.FileSystem)
- func (c *Context) GetFormFile(key string) (*multipart.FileHeader, error)
- func (c *Context) GetKey(keyName string) (any, bool)
- func (c *Context) GetMultipartForm() (*multipart.Form, error)
- func (c *Context) GetPostForm(key string) any
- func (c *Context) GetPostFormArray(key string) ([]string, bool)
- func (c *Context) GetQuery(key string) any
- func (c *Context) GetQueryArray(key string) ([]string, bool)
- func (c *Context) HTML(code int, html string) error
- func (c *Context) HTMLTemplate(code int, name string, data any) error
- func (c *Context) HTMLTemplateGlob(code int, name string, data interface{}, pattern string) error
- func (c *Context) JSON(code int, data any) error
- func (c *Context) MustBindWith(obj any, binding binding.Binding) error
- func (c *Context) Next()
- func (c *Context) Redirect(code int, url string) error
- func (c *Context) Render(w http.ResponseWriter, r render.Render) error
- func (c *Context) SaveUploadFile(fileHeader *multipart.FileHeader, savePath string) error
- func (c *Context) SetBasicAuth(username string, password string)
- func (c *Context) SetHeader(key string, value string)
- func (c *Context) SetKey(keyName string, keyValue any)
- func (c *Context) Status(code int)
- func (c *Context) String(code int, format string, data ...any) error
- func (c *Context) XML(code int, data any) error
- type Dog
- func (dog *Dog) Handle() *Dog
- func (dog *Dog) HttpRequestHandler(ctx *Context)
- func (dog *Dog) LoadTemplate(pattern string)
- func (dog *Dog) RegisterRouterGroup(groups ...*RouterGroup)
- func (dog *Dog) RegisterRouters(routers ...*Router)
- func (dog *Dog) Run(host string, port int)
- func (dog *Dog) RunTLS(host string, port int, certFile string, keysFile string)
- func (dog *Dog) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (dog *Dog) SetFuncMap(funcMap template.FuncMap)
- func (dog *Dog) SetLogPath(logPath string)
- func (dog *Dog) SetTemplate(tmpl *template.Template)
- type DogError
- type DogErrorFunc
- type HandlerFuc
- type Router
- func (r *Router) DELETE(pattern string, handler HandlerFuc)
- func (r *Router) GET(pattern string, handler HandlerFuc)
- func (r *Router) POST(pattern string, handler HandlerFuc)
- func (r *Router) PUT(pattern string, handler HandlerFuc)
- func (r *Router) PostHandle(handler ...HandlerFuc)
- func (r *Router) PreHandle(handler ...HandlerFuc)
- func (r *Router) Use(handler ...HandlerFuc)
- type RouterGroup
- func (rg *RouterGroup) DELETE(pattern string, handler HandlerFuc)
- func (rg *RouterGroup) GET(pattern string, handler HandlerFuc)
- func (rg *RouterGroup) POST(pattern string, handler HandlerFuc)
- func (rg *RouterGroup) PUT(pattern string, handler HandlerFuc)
- func (rg *RouterGroup) PostHandle(handler ...HandlerFuc)
- func (rg *RouterGroup) PreHandle(handler ...HandlerFuc)
- func (rg *RouterGroup) Use(handler ...HandlerFuc)
- type Trie
- type TrieNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Account ¶
func (*Account) BasicAuthHandler ¶
type Context ¶
type Context struct { // 请求数据 Method string Path string // 响应数据 Code int // 其它参数 Keys map[string]any DisallowUnknownFields bool // 是否校验json对应结构体字段 // contains filtered or unexported fields }
Context 上下文封装
func (*Context) FileAttachment ¶
FileAttachment 自定义文件名下载
func (*Context) FileFromFS ¶
func (c *Context) FileFromFS(code int, filepath string, fs http.FileSystem)
FileFromFS 从文件系统获取下载(filepath是相对于文件系统的路径)
func (*Context) GetFormFile ¶
func (c *Context) GetFormFile(key string) (*multipart.FileHeader, error)
GetFormFile 获取表单文件,返回文件头
func (*Context) GetMultipartForm ¶
GetMultipartForm 获取原始MultipartForm
func (*Context) GetPostFormArray ¶
GetPostFormArray 获取postForm切片
func (*Context) GetQueryArray ¶
GetQueryArray 获取query参数切片
func (*Context) HTMLTemplate ¶
HTMLTemplate 响应HTML模板
func (*Context) HTMLTemplateGlob ¶
func (*Context) MustBindWith ¶
func (*Context) SaveUploadFile ¶
func (c *Context) SaveUploadFile(fileHeader *multipart.FileHeader, savePath string) error
SaveUploadFile 封装文件上传并保存的方法
func (*Context) SetBasicAuth ¶
SetBasicAuth 设置Basic认证
type Dog ¶
type Dog struct { Routers []*Router RouterGroups []*RouterGroup Middlewares []HandlerFuc TmplFuncMap template.FuncMap HTMLRender render.HTMLRender // contains filtered or unexported fields }
Dog 核心引擎结构体
func (*Dog) HttpRequestHandler ¶
HttpRequestHandler 预处理Http请求
func (*Dog) RegisterRouterGroup ¶
func (dog *Dog) RegisterRouterGroup(groups ...*RouterGroup)
RegisterRouterGroup 解析路由组,将路由注册到引擎
func (*Dog) RegisterRouters ¶
RegisterRouters 将路由注册到引擎
func (*Dog) SetFuncMap ¶
SetFuncMap 设置模板渲染过程中可能使用的自定义函数
func (*Dog) SetTemplate ¶
SetTemplate 允许开发者自己设置模板
type DogError ¶
type DogError struct {
// contains filtered or unexported fields
}
func (*DogError) ExecuteError ¶
func (der *DogError) ExecuteError()
func (*DogError) Result ¶
func (der *DogError) Result(fn DogErrorFunc)
type HandlerFuc ¶
type HandlerFuc func(ctx *Context)
type Router ¶
type Router struct { RouterTrie Trie HandlerMap map[string]HandlerFuc PreHandlers []HandlerFuc PostHandlers []HandlerFuc }
Router 路由
func (*Router) DELETE ¶
func (r *Router) DELETE(pattern string, handler HandlerFuc)
func (*Router) GET ¶
func (r *Router) GET(pattern string, handler HandlerFuc)
func (*Router) POST ¶
func (r *Router) POST(pattern string, handler HandlerFuc)
func (*Router) PUT ¶
func (r *Router) PUT(pattern string, handler HandlerFuc)
type RouterGroup ¶
RouterGroup 路由组
func NewRouterGroup ¶
func NewRouterGroup(name string) *RouterGroup
func (*RouterGroup) DELETE ¶
func (rg *RouterGroup) DELETE(pattern string, handler HandlerFuc)
func (*RouterGroup) GET ¶
func (rg *RouterGroup) GET(pattern string, handler HandlerFuc)
func (*RouterGroup) POST ¶
func (rg *RouterGroup) POST(pattern string, handler HandlerFuc)
func (*RouterGroup) PUT ¶
func (rg *RouterGroup) PUT(pattern string, handler HandlerFuc)
func (*RouterGroup) PostHandle ¶
func (rg *RouterGroup) PostHandle(handler ...HandlerFuc)
PostHandle 插入后置中间件
func (*RouterGroup) PreHandle ¶
func (rg *RouterGroup) PreHandle(handler ...HandlerFuc)
PreHandle 插入前置中间件
Source Files ¶
Click to show internal directories.
Click to hide internal directories.