Documentation
¶
Index ¶
- func NewRoute(cfg contracts.Config, validator contracts.Validation, ...) (contracts.Route, error)
- type Context
- func (ctx *Context) Abort() error
- func (ctx *Context) AbortWithCode(code int) error
- func (ctx *Context) AbortWithJson(code int, obj any) error
- func (ctx *Context) Bind(obj any) error
- func (ctx *Context) BodyRaw() []byte
- func (ctx *Context) ClearCookie(name string)
- func (ctx *Context) ContentType() string
- func (ctx *Context) Cookie(name string) string
- func (ctx *Context) File(key string) (contracts.File, error)
- func (ctx *Context) Files(key string) ([]contracts.File, error)
- func (ctx *Context) FormValue(key string) string
- func (ctx *Context) FullPath() string
- func (ctx *Context) HTML(code int, name string, data any) error
- func (ctx *Context) Header(key string) string
- func (ctx *Context) IP() string
- func (ctx *Context) JSON(code int, obj any) error
- func (ctx *Context) Method() string
- func (ctx *Context) Next() error
- func (ctx *Context) Param(key string) string
- func (ctx *Context) Path() string
- func (ctx *Context) Query(key string, defaultValue ...string) string
- func (ctx *Context) QueryBool(key string, defaultValue ...bool) bool
- func (ctx *Context) QueryFloat64(key string, defaultValue ...float64) float64
- func (ctx *Context) QueryInt(key string, defaultValue ...int) int
- func (ctx *Context) QueryInt64(key string, defaultValue ...int64) int64
- func (ctx *Context) Redirect(code int, location string) error
- func (ctx *Context) Response() contracts.Response
- func (ctx *Context) SendFile(path string) error
- func (ctx *Context) SetCookie(name, value string, opts contracts.CookieOptions)
- func (ctx *Context) SetHeader(key, value string) contracts.Context
- func (ctx *Context) Status(code int) contracts.Context
- func (ctx *Context) Storage() contracts.Storage
- func (ctx *Context) String(code int, s string) error
- func (ctx *Context) Underlying() any
- func (ctx *Context) UserAgent() string
- func (ctx *Context) Value(key string) any
- func (ctx *Context) WithValue(key string, value any) contracts.Context
- func (ctx *Context) Write(data []byte) error
- type ServiceProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context 实现 contracts.Context,内部包装 *gin.Context。 应用代码只见 contracts.Context,不感知 Gin。
func NewContext ¶
func NewContext(c *gin.Context, v contracts.Validation, s contracts.Storage, ve contracts.ViewEngine) *Context
NewContext 创建 Gin 上下文包装器。
func (*Context) AbortWithCode ¶
func (*Context) Bind ¶
Bind 将请求数据填充到 obj(URI → Query → Body),最后统一验证。
- `uri:"xxx"` → URL 路径参数
- `query:"xxx"` → Query String
- `json:"xxx"` → 请求体(仅有 body 时解析)
func (*Context) ClearCookie ¶
func (*Context) ContentType ¶
func (*Context) QueryFloat64 ¶
func (*Context) QueryInt64 ¶
func (*Context) SetCookie ¶
func (ctx *Context) SetCookie(name, value string, opts contracts.CookieOptions)
func (*Context) Underlying ¶
Underlying 返回底层 *gin.Context,用于 SSE 等高级场景。
type ServiceProvider ¶
type ServiceProvider struct{}
ServiceProvider Gin HTTP 驱动接入点(可选驱动,需显式加入应用 providers)。
import gofastgin "github.com/zhoudm1743/gofast-gin"
app.SetProviders(append(providers, &gofastgin.ServiceProvider{}))
配置 server.driver: gin
func (*ServiceProvider) Boot ¶
func (sp *ServiceProvider) Boot(app foundation.Application) error
func (*ServiceProvider) Register ¶
func (sp *ServiceProvider) Register(app foundation.Application)
Click to show internal directories.
Click to hide internal directories.