Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HttpContext ¶
type HttpContext struct {
Request *HttpRequest
Response *HttpResponse
Header collections.ReadonlyDictionary[string, string]
Route *HttpRoute
URI *HttpURL
Method string
ContentLength int64
Close bool
TransferEncoding []string
ContentType string
Exception any
}
func NewHttpContext ¶
func NewHttpContext(httpRoute HttpRoute, w http.ResponseWriter, r *http.Request) HttpContext
NewHttpContext 初始化上下文
func (*HttpContext) BuildActionInValue ¶ added in v0.3.0
func (httpContext *HttpContext) BuildActionInValue() []reflect.Value
BuildActionInValue 根据method映射入参
func (*HttpContext) IsActionResult ¶
func (httpContext *HttpContext) IsActionResult() bool
IsActionResult 是否为ActionResult类型
type HttpRequest ¶
type HttpRequest struct {
Body io.ReadCloser
BodyString string
BodyBytes []byte
Form map[string]any
Query map[string]any
R *http.Request
}
func (*HttpRequest) JsonToMap ¶
func (r *HttpRequest) JsonToMap() map[string]any
JsonToMap 将json转成map类型
func (*HttpRequest) ParseForm ¶
func (r *HttpRequest) ParseForm()
func (*HttpRequest) ParseQuery ¶
func (r *HttpRequest) ParseQuery(values url.Values)
type HttpResponse ¶
type HttpResponse struct {
Body []reflect.Value
BodyString string
BodyBytes []byte
W http.ResponseWriter
StatusCode int
}
func (HttpResponse) AddHeader ¶
func (receiver HttpResponse) AddHeader(key, value string)
AddHeader 添加头部
func (HttpResponse) SetHeader ¶
func (receiver HttpResponse) SetHeader(key, value string)
SetHeader 覆盖头部
func (HttpResponse) Write ¶
func (receiver HttpResponse) Write(content []byte) (int, error)
Write 将响应内容写入http流
func (HttpResponse) WriteCode ¶
func (receiver HttpResponse) WriteCode(statusCode int)
WriteCode 将响应状态写入http流
type HttpRoute ¶
type HttpRoute struct {
RouteUrl string // 路由地址
Controller reflect.Type // 控制器类型
ControllerName string // 控制器名称
Action any // action类型
ActionName string // action名称
RequestParamType collections.List[reflect.Type] // 入参
ResponseBodyType collections.List[reflect.Type] // 出参
Method collections.List[string] // method
ParamNames collections.List[string] // 入参变量名称
RequestParamIsModel bool // 是否为DTO结构
ResponseBodyIsModel bool // 是否为DTO结构
AutoBindHeaderName string // 自动绑定header的字段名称
IsImplActionFilter bool // 是否实现了IActionFilter
IsGoBasicType bool // 返回值只有一个时,是否为基础类型
HttpMiddleware IMiddleware // 中间件入口
HandleMiddleware IMiddleware // handle中间件
}
HttpRoute 路由表
type IMiddleware ¶ added in v0.3.0
type IMiddleware interface {
Invoke(httpContext *HttpContext)
}
IMiddleware 中间件
Click to show internal directories.
Click to hide internal directories.