Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var LstRouteTable collections.List[HttpRoute]
Functions ¶
This section is empty.
Types ¶
type HttpContext ¶
type HttpContext struct {
Request *HttpRequest
Response *HttpResponse
Header collections.Dictionary[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) GetRequestParam ¶
func (httpContext *HttpContext) GetRequestParam() []reflect.Value
GetRequestParam 根据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
}
func (*HttpRequest) JsonToMap ¶
func (r *HttpRequest) JsonToMap() map[string]any
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
StatusCode int
// contains filtered or unexported fields
}
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 string
ParamNames collections.List[string]
RequestParamIsModel bool // 是否为DTO结构
ResponseBodyIsModel bool // 是否为DTO结构
}
HttpRoute 路由表
Click to show internal directories.
Click to hide internal directories.