Documentation ¶
Index ¶
- Constants
- type Api
- type BytesBody
- type Context
- func (c *Context) GetBytesBody() (*BytesBody, error)
- func (c *Context) GetFileHeaderBytes(fileHeader *multipart.FileHeader) (string, []byte, error)
- func (c *Context) GetHeader() *Header
- func (c *Context) GetJsonBody() (*JsonBody, error)
- func (c *Context) GetPathParams() *PathPrams
- func (c *Context) GetQueryParams() *QueryPrams
- func (c *Context) GetTenantInfo() TenantInfo
- func (c *Context) GetUserInfo() UserInfo
- func (c *Context) SetTenantInfo(tenantInfo TenantInfo)
- func (c *Context) SetUserInfo(userInfo UserInfo)
- type Handler
- type Header
- type JsonBody
- type Option
- type Options
- type PathPrams
- type PrefixRouter
- func (r *PrefixRouter) AddMiddlewares(middlewares ...Handler) Router
- func (r *PrefixRouter) AddRoute(method string, relativePath string, handlers ...Handler) Router
- func (r *PrefixRouter) BasePath() string
- func (r *PrefixRouter) RegisterVersionedRouter(version string, middlewares ...Handler) Router
- func (r *PrefixRouter) Static(relativePath string, root string)
- func (r *PrefixRouter) StaticFile(relativePath string, filepath string)
- func (r *PrefixRouter) VersionedRouter(version string) Router
- type QueryPrams
- type RootRouter
- func (r *RootRouter) AddMiddlewares(middlewares ...Handler) Router
- func (r *RootRouter) AddRoute(method string, relativePath string, handlers ...Handler) Router
- func (r *RootRouter) BasePath() string
- func (r *RootRouter) RegisterVersionedRouter(version string, middlewares ...Handler) Router
- func (r *RootRouter) ServerHttp(w http.ResponseWriter, req *http.Request)
- func (r *RootRouter) Static(relativePath string, root string)
- func (r *RootRouter) StaticFile(relativePath string, filepath string)
- func (r *RootRouter) VersionedRouter(version string) Router
- type Router
- type TenantInfo
- type UserInfo
Constants ¶
const ( RouterRoot = "root" RouterPrefix = "prefix" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Api ¶
type Api struct {
// contains filtered or unexported fields
}
func NewWithEngine ¶ added in v0.3.0
func (*Api) ChooseRouter ¶ added in v0.2.2
ChooseRouter 选择Router 参数: - routerType: 路由类型,有两种
- api.RouterRoot: 根路由
- api.RouterPrefix: 带url前缀的路由
- version: 版本,用于获取基于上面两中路由够造的带有版本号的路由,传空字符串则选定上面两种路由本身 返回值: - 选择的Router
func (*Api) PrefixRouter ¶
PrefixRouter 获取Api的前缀路由 参数: 无 返回值: - Api的前缀路由
func (*Api) RootRouter ¶
RootRouter 获取Api的根路由 参数: 无 返回值: - Api的根路由
type BytesBody ¶ added in v0.10.12
type BytesBody struct {
// contains filtered or unexported fields
}
func (*BytesBody) Marshal ¶ added in v0.10.12
Marshal 将input Marshal到字节body 参数: - input: 输入,一般为结构或map[string]any 返回值: - 错误
type Context ¶
func (*Context) GetBytesBody ¶ added in v0.6.0
GetBytesBody 获取上下文中的字节Body 参数: 无 返回值: - 上下文中的字节Body - 错误
func (*Context) GetFileHeaderBytes ¶
GetFileHeaderBytes 获取Multipart中传递的文件名和文件内容 参数: - fileHeader: Multipart的文件头 返回值: - 文件名 - 文件字节 - 错误
func (*Context) GetJsonBody ¶ added in v0.6.0
GetJsonBody 获取上下文中的JsonBody 参数: 无 返回值: - 上下文中的JsonBody - 错误
func (*Context) GetPathParams ¶ added in v0.6.0
GetPathParams 获取上下文中的路径参数 参数: 无 返回值: - 上下文中的路径参数 - 错误
func (*Context) GetQueryParams ¶ added in v0.6.0
func (c *Context) GetQueryParams() *QueryPrams
GetQueryParams 获取上下文中的查询参数 参数: 无 返回值: - 上下文中的查询参数 - 错误
func (*Context) GetTenantInfo ¶ added in v0.4.0
func (c *Context) GetTenantInfo() TenantInfo
func (*Context) GetUserInfo ¶ added in v0.4.0
func (*Context) SetTenantInfo ¶ added in v0.8.0
func (c *Context) SetTenantInfo(tenantInfo TenantInfo)
func (*Context) SetUserInfo ¶ added in v0.8.0
type Header ¶ added in v0.10.1
type Header struct {
// contains filtered or unexported fields
}
type JsonBody ¶ added in v0.6.0
type JsonBody struct {
// contains filtered or unexported fields
}
func (*JsonBody) Get ¶ added in v0.6.0
Get 获取JsonBody对应键的值 参数: - key: JsonBody的键 返回值: - JsonBody对应键的值
type Option ¶
type Option func(options *Options)
func WithLogSkipPaths ¶ added in v0.10.12
WithLogSkipPaths 设置日志跳过的打印路径
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func (Options) GetUrlPrefix ¶
type PathPrams ¶ added in v0.6.0
type PathPrams struct {
// contains filtered or unexported fields
}
type PrefixRouter ¶
type PrefixRouter struct {
// contains filtered or unexported fields
}
func (*PrefixRouter) AddMiddlewares ¶
func (r *PrefixRouter) AddMiddlewares(middlewares ...Handler) Router
func (*PrefixRouter) AddRoute ¶
func (r *PrefixRouter) AddRoute(method string, relativePath string, handlers ...Handler) Router
func (*PrefixRouter) BasePath ¶
func (r *PrefixRouter) BasePath() string
func (*PrefixRouter) RegisterVersionedRouter ¶
func (r *PrefixRouter) RegisterVersionedRouter(version string, middlewares ...Handler) Router
func (*PrefixRouter) Static ¶
func (r *PrefixRouter) Static(relativePath string, root string)
func (*PrefixRouter) StaticFile ¶
func (r *PrefixRouter) StaticFile(relativePath string, filepath string)
func (*PrefixRouter) VersionedRouter ¶
func (r *PrefixRouter) VersionedRouter(version string) Router
type QueryPrams ¶ added in v0.6.0
type QueryPrams struct {
// contains filtered or unexported fields
}
func (*QueryPrams) Delete ¶ added in v0.6.0
func (queryParams *QueryPrams) Delete(key string)
Delete 删除JsonBody键对应的值 参数: - key: JsonBody的键 返回值: 无
func (*QueryPrams) Get ¶ added in v0.6.0
func (queryParams *QueryPrams) Get(key string) string
Get 获取查询参数对应键的值 参数: - key: 查询参数的键 返回值: - 查询参数对应键的值
func (*QueryPrams) Map ¶ added in v0.6.0
func (queryParams *QueryPrams) Map() map[string]string
Map 获取查询参数的map表示 参数: 无 返回值: - 查询参数的map表示
func (*QueryPrams) Set ¶ added in v0.6.0
func (queryParams *QueryPrams) Set(key string, value string)
Set 设置查询参数 参数: - key: 查询参数的键 - value: 查询参数对应键的值 返回值: 无
type RootRouter ¶
type RootRouter struct {
// contains filtered or unexported fields
}
func (*RootRouter) AddMiddlewares ¶
func (r *RootRouter) AddMiddlewares(middlewares ...Handler) Router
func (*RootRouter) AddRoute ¶
func (r *RootRouter) AddRoute(method string, relativePath string, handlers ...Handler) Router
func (*RootRouter) BasePath ¶
func (r *RootRouter) BasePath() string
func (*RootRouter) RegisterVersionedRouter ¶
func (r *RootRouter) RegisterVersionedRouter(version string, middlewares ...Handler) Router
func (*RootRouter) ServerHttp ¶
func (r *RootRouter) ServerHttp(w http.ResponseWriter, req *http.Request)
func (*RootRouter) Static ¶
func (r *RootRouter) Static(relativePath string, root string)
func (*RootRouter) StaticFile ¶
func (r *RootRouter) StaticFile(relativePath string, filepath string)
func (*RootRouter) VersionedRouter ¶
func (r *RootRouter) VersionedRouter(version string) Router
type Router ¶
type Router interface { // AddMiddlewares 添加中间件 AddMiddlewares(middlewares ...Handler) Router // RegisterVersionedRouter 注册版本路由 RegisterVersionedRouter(version string, middlewares ...Handler) Router // VersionedRouter 获取版本路由 VersionedRouter(version string) Router // AddRoute 添加路由路径 AddRoute(method string, relativePath string, handlers ...Handler) Router // Static 静态路由(指向目录) Static(relativePath string, root string) // StaticFile 静态路由(指向文件) StaticFile(relativePath string, filepath string) // BasePath 路由的基础路径,即去掉http://ip:port之后的URL部分(不包括AddRoute的RelativePath) BasePath() string }
Router 路由接口