Documentation ¶
Index ¶
- func Dir(root string, listDirectory bool) http.FileSystem
- type Context
- func (c *Context) Abort()
- func (c *Context) AbortWithStatus(code int)
- func (c *Context) Deadline() (deadline time.Time, ok bool)
- func (c *Context) Done() <-chan struct{}
- func (c *Context) Err() error
- func (c *Context) File(filepath string)
- func (c *Context) FileFromFS(filepath string, fs http.FileSystem)
- func (c *Context) Header(key, value string)
- func (c *Context) IsAborted() bool
- func (c *Context) JSON(code int, obj any)
- func (c *Context) Next()
- func (c *Context) Render(code int, r render.Render)
- func (c *Context) Status(code int)
- func (c *Context) Value(key any) any
- type Error
- type Gateway
- type GatewayConf
- type H
- type HandlerFunc
- type IRoutes
- type Response
- type RouterGroup
- func (r *RouterGroup) DELETE(path string, handler HandlerFunc) IRoutes
- func (r *RouterGroup) GET(path string, handler HandlerFunc) IRoutes
- func (r *RouterGroup) Group(relativePath string, handlers ...HandlerFunc) *RouterGroup
- func (r *RouterGroup) HEAD(path string, handler HandlerFunc) IRoutes
- func (r *RouterGroup) OPTIONS(path string, handler HandlerFunc) IRoutes
- func (r *RouterGroup) PATCH(path string, handler HandlerFunc) IRoutes
- func (r *RouterGroup) POST(path string, handler HandlerFunc) IRoutes
- func (r *RouterGroup) PUT(path string, handler HandlerFunc) IRoutes
- func (r *RouterGroup) StaticFile(relativePath, filepath string) IRoutes
- func (r *RouterGroup) StaticFileFS(relativePath, filepath string, fs http.FileSystem) IRoutes
- func (r *RouterGroup) Use(middleware ...HandlerFunc) IRoutes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dir ¶
func Dir(root string, listDirectory bool) http.FileSystem
Dir returns a http.Filesystem that can be used by http.FileServer(). It is used internally in router.Static(). if listDirectory == true, then it works the same as http.Dir() otherwise it returns a filesystem that prevents http.FileServer() to list the directory files.
Types ¶
type Context ¶
type Context struct { Writer responseWriter Request *http.Request PathParams map[string]string Path string Method string StatusCode int // contains filtered or unexported fields }
Context gateway 自定义路由上下文解析
func (*Context) AbortWithStatus ¶
AbortWithStatus 调用 Abort 并返回指定状态码
func (*Context) FileFromFS ¶
func (c *Context) FileFromFS(filepath string, fs http.FileSystem)
FileFromFS 通过 http.FileSystem 启动一个文件流服务 filepath: 路径参数名, 从请求路径中获取到filepath的地址信息,将信息当作路由
type Gateway ¶
type Gateway struct { RouterGroup // contains filtered or unexported fields }
func (*Gateway) GetServerMux ¶
type GatewayConf ¶
type GatewayConf struct {
Port string
}
type HandlerFunc ¶
type HandlerFunc func(ctx *Context)
type IRoutes ¶
type IRoutes interface { Use(...HandlerFunc) IRoutes GET(string, HandlerFunc) IRoutes POST(string, HandlerFunc) IRoutes DELETE(string, HandlerFunc) IRoutes PATCH(string, HandlerFunc) IRoutes PUT(string, HandlerFunc) IRoutes OPTIONS(string, HandlerFunc) IRoutes HEAD(string, HandlerFunc) IRoutes StaticFile(string, string) IRoutes StaticFileFS(string, string, http.FileSystem) IRoutes }
IRoutes 定义所有路由器句柄接口
type RouterGroup ¶
type RouterGroup struct { // 路由中间件 Handlers []HandlerFunc // contains filtered or unexported fields }
RouterGroup 内部路由器配置
func (*RouterGroup) DELETE ¶
func (r *RouterGroup) DELETE(path string, handler HandlerFunc) IRoutes
func (*RouterGroup) GET ¶
func (r *RouterGroup) GET(path string, handler HandlerFunc) IRoutes
func (*RouterGroup) Group ¶
func (r *RouterGroup) Group(relativePath string, handlers ...HandlerFunc) *RouterGroup
Group 路由分组
func (*RouterGroup) HEAD ¶
func (r *RouterGroup) HEAD(path string, handler HandlerFunc) IRoutes
func (*RouterGroup) OPTIONS ¶
func (r *RouterGroup) OPTIONS(path string, handler HandlerFunc) IRoutes
func (*RouterGroup) PATCH ¶
func (r *RouterGroup) PATCH(path string, handler HandlerFunc) IRoutes
func (*RouterGroup) POST ¶
func (r *RouterGroup) POST(path string, handler HandlerFunc) IRoutes
func (*RouterGroup) PUT ¶
func (r *RouterGroup) PUT(path string, handler HandlerFunc) IRoutes
func (*RouterGroup) StaticFile ¶
func (r *RouterGroup) StaticFile(relativePath, filepath string) IRoutes
func (*RouterGroup) StaticFileFS ¶
func (r *RouterGroup) StaticFileFS(relativePath, filepath string, fs http.FileSystem) IRoutes
func (*RouterGroup) Use ¶
func (r *RouterGroup) Use(middleware ...HandlerFunc) IRoutes
Source Files ¶
Click to show internal directories.
Click to hide internal directories.