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)
- func View(html string, rew http.ResponseWriter, data web.Context)
- type Catch
- type ContentType
- type Controller
- type Proxy
- type Router
- func (router *Router) Cache(method string, url string, control any, middleware ...web.Middleware)
- func (router *Router) Catch(err any)
- func (router *Router) Constraint(tag string, verify web.Verify)
- func (router *Router) LoadCache()
- func (router *Router) Recover(webRecover web.Recover)
- func (router *Router) Register(method, path string, control any, middleware ...web.Middleware)
- func (router *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func (router *Router) Use(middleware ...web.Middleware)
- type ViewHandle
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 web.Context //上下文数据 UrlVariable []string //路径参数,按顺序依次 RESTFul map[string]any // K/V 路径参数 控制器解析中,请求参数参数名尽量不要和 RESTFul 参数同名,否则会覆盖 InNum int //处理器入参参数个数 OutNum int //处理器返回值个数 InvokeValues []reflect.Value // InvokeValues存储的是控制器传递参数的序列 按顺序存储每个入参的反射实例 Args []string //参数赋值序列表,主要存储请求参数的只值 AssignmentIndex []int //AssignmentIndex 可赋值参数索引序列,可赋值参数序列是存储了系统内部参数之外的请求参数所在 InvokeValues 参数序列中的索引位置。 ReturnValues []reflect.Value //返回参数实例 Fun reflect.Value //将被调用的函数,注册阶段已经被构建成为反射类型 FunType reflect.Type Intrinsic map[string]web.Variate // 自定赋值参数列表(系统参数配置) }
func (*Controller) InitArgs ¶
func (control *Controller) InitArgs()
InitArgs 初始化参数信息,注册函数阶段调用 完成对 InvokeValues 控制器参数的初始化(未赋值状态) 完成对应的 AssignmentIndex 可赋值参数序列初始化
type Proxy ¶
type Proxy struct { *Router Rew http.ResponseWriter // http 响应体 Req *http.Request // http 请求体 Middleware []web.Middleware // 当前控制器待执行中间件 Context web.Context // 请求上下文数据 File *web.MultipartFile // Post文件上传解析值 Control Controller // 待处理执行器 UrlVariable []string // RESTFul 顺序值 RESTFul map[string]any // RESTFul K/V值 Recover web.Recover // 路由错误捕捉器 // contains filtered or unexported fields }
Proxy 主要完成 接口调用 和 处理响应
type Router ¶
type Router struct { web.Log Recovers web.Recover MaxMultipartMemory int64 Root string // 项目更目录 Resource string // 静态资源管理 默认为 root 目录 FileService string // 文件服务配置 ProxyPool *sync.Pool // 创建执行实例 PathPool *sync.Pool // 分配路径构建 Catches map[reflect.Type]Catch // 全局错误捕捉处理 Api map[string][]web.ControlInfo // 接口信息 Constraints map[string]web.Verify Middlewares []web.Middleware // 全局中间件 Controllers []*reflect.Value // 存储结构体全局控制器 DefaultView web.ViewHandle // 默认视图处理器,初始化采用 Aurora 实现的函数进行渲染 Intrinsic map[string]web.Variate // 自定义系统参 初始化来自 Engine Tree map[string]*node // 路由树根节点 Mux *sync.Mutex // 注册路由并发锁 // contains filtered or unexported fields }
Router Aurora 核心路由器
func (*Router) Constraint ¶ added in v1.3.5
Constraint 自定义约束注册
func (*Router) Register ¶
func (router *Router) Register(method, path string, control any, middleware ...web.Middleware)
Register 预处理被添加路径 method: 请求类型 path :注册路径 control : 处理器(需要传递函数) middleware : 路径中间件
func (*Router) ServeHTTP ¶
func (router *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP 一切的开始
func (*Router) Use ¶
func (router *Router) Use(middleware ...web.Middleware)
type ViewHandle ¶
type ViewHandle func(string, http.ResponseWriter, web.Context)
ViewHandle 是整个服务器对视图渲染的核心函数,开发者实现改接口对需要展示的页面进行自定义处理
Click to show internal directories.
Click to hide internal directories.