Documentation ¶
Index ¶
- Constants
- func ErrorMsg(err error, msg ...string)
- func GetRequest(request *http.Request, control *Controller) []string
- func PostRequest(request *http.Request, control *Controller) []string
- func RESTFul(n *Node, mapping string) ([]string, map[string]any)
- type Catch
- type ContentType
- type Controller
- type Node
- type Proxy
- type Route
- type Router
- func (router *Router) Cache(method string, url string, control any, interceptor ...web.Interceptor)
- func (router *Router) Catch(err any)
- func (router *Router) Constraint(tag string, verify web.Verify)
- func (router *Router) DefaultRoute(route Route)
- func (router *Router) FileServer(path string)
- func (router *Router) Interceptors(interceptors ...web.Interceptor)
- func (router *Router) LoadCache()
- func (router *Router) Recover(webRecover web.Recover)
- func (router *Router) Register(method, path string, control any, interceptor ...web.Interceptor)
- func (router *Router) Search(root *Node, path string) (*Node, []string, map[string]any)
- func (router *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func (router *Router) Static(fs embed.FS)
Constants ¶
View Source
const ( DefaultType = iota RESTFulType )
Variables ¶
This section is empty.
Functions ¶
func GetRequest ¶
func GetRequest(request *http.Request, control *Controller) []string
func PostRequest ¶
func PostRequest(request *http.Request, control *Controller) []string
Types ¶
type Controller ¶
type Controller struct { *Proxy Constraints map[string]web.Verify // Context 上下文数据 Context web.Context // UrlVariable 路径参数,按顺序依次 UrlVariable []string // K/V 路径参数 控制器解析中,请求参数参数名尽量不要和 RESTFul 参数同名,否则会覆盖 RESTFul map[string]any // InNum 处理器入参参数个数 InNum int // OutNum 处理器返回值个数 OutNum int // InvokeValues 存储的是控制器传递参数的序列 按顺序存储每个入参的反射实例 InvokeValues []reflect.Value // Args 参数赋值序列表,主要存储请求参数的只值, Args 和 InvokeValues 的元素是一一对应的 Args []string // AssignmentIndex 可赋值参数索引序列 // 可赋值参数序列是存储了系统内部参数之外的请求参数所在 InvokeValues 参数序列中的索引位置。 AssignmentIndex []int // ReturnValues 返回参数实例 ReturnValues []reflect.Value Fun reflect.Value //将被调用的函数,注册阶段已经被构建成为反射类型 FunType reflect.Type // Intrinsic 自定赋值参数列表(包括系统参数配置) Intrinsic map[string]web.Variate }
func (*Controller) InitArgs ¶
func (control *Controller) InitArgs()
InitArgs 初始化参数信息,注册函数阶段调用 完成对 InvokeValues 控制器参数的初始化(未赋值状态) 完成对应的 AssignmentIndex 可赋值参数序列初始化
type Node ¶ added in v1.3.15
type Node struct { Path string //当前节点路径 FullPath string //当前处理器全路径 NodeType int //节点类型 Count int //路径数量 Control *Controller //服务处理函数 Child []*Node //子节点 // contains filtered or unexported fields }
Node 路由节点
type Proxy ¶
type Proxy struct { *Router Rew http.ResponseWriter // http 响应体 Req *http.Request // http 请求体 Inter []web.Interceptor // 拦截器 Context web.Context // 请求上下文数据 File *web.MultipartFile // Post文件上传解析值 Control Controller // 待处理执行器 UrlVariable []string // RESTFul 顺序值 RESTFul map[string]any // RESTFul K/V值 Recover web.Recover // 路由错误捕捉器 Status int // 解析 values 后需要响应的具体 http状态码 Data []byte // 解析 values 后需要响应的具体数据 Error error //错误消息 // contains filtered or unexported fields }
Proxy 主要完成 接口调用 和 处理响应
type Router ¶
type Router struct { *zap.Logger Cors web.CorsHandle Recovers web.Recover // 错误捕捉 MaxMultipartMemory int64 // 文件上传大小 Root string // 项目根目录 Resource string // 静态资源管理 默认为 root 目录 FileService string // 文件服务配置 ProxyPool *sync.Pool // 创建执行实例 Catches map[reflect.Type]Catch // 全局错误捕捉处理 弃用 Api map[string][]web.ControlInfo // 接口信息 Constraints map[string]web.Verify // 自定义参数校验器 Interceptor []web.Interceptor Controllers []*reflect.Value // 存储结构体全局控制器 DefaultView web.ViewHandle // 默认视图处理器,初始化采用 web包 的函数进行渲染 Intrinsic map[string]web.Variate // 自定义系统参 初始化来自 Engine Tree map[string]*Node // 路由树根节点 Mux *sync.Mutex // 注册路由并发锁 validator.Validate // contains filtered or unexported fields }
Router Aurora 核心路由器
func (*Router) Constraint ¶ added in v1.3.5
Constraint 自定义约束注册
func (*Router) DefaultRoute ¶ added in v1.3.15
DefaultRoute 使用自定义 路由规则 需要实现 Route 接口
func (*Router) FileServer ¶ added in v1.3.9
func (*Router) Interceptors ¶ added in v1.3.17
func (router *Router) Interceptors(interceptors ...web.Interceptor)
func (*Router) Register ¶
func (router *Router) Register(method, path string, control any, interceptor ...web.Interceptor)
Register 预处理被添加路径 method: 请求类型 path :注册路径 control : 处理器(需要传递函数) middleware : 路径中间件
Click to show internal directories.
Click to hide internal directories.