Documentation
¶
Overview ¶
Package fastapi FastApi-Python 的Golang实现
其提供了类似于FastAPI的API设计,并提供了接口文档自动生成、请求体自动校验和返回值自动序列化等使用功能;
Index ¶
- Constants
- Variables
- func CombinePath(prefix, path string) string
- func DoesPathParamsFound(path string) (map[string]bool, bool)
- type BaseModel
- type BaseModelIface
- type Config
- type Context
- func (c *Context) AdvancedResponse(statusCode int, content fiber.Handler) *Response
- func (c *Context) AnyResponse(statusCode int, content any, contentType string) *Response
- func (c *Context) BodyParser(a any) *Response
- func (c *Context) DisposableCtx() context.Context
- func (c *Context) Done() <-chan struct{}
- func (c *Context) EngineCtx() *fiber.Ctx
- func (c *Context) ErrorResponse(content any) *Response
- func (c *Context) F(s ...string) string
- func (c *Context) FileResponse(filepath string) *Response
- func (c *Context) HTMLResponse(statusCode int, context string) *Response
- func (c *Context) JSONResponse(statusCode int, content any) *Response
- func (c *Context) Logger() logger.Iface
- func (c *Context) Marshal(obj any) ([]byte, error)
- func (c *Context) OKResponse(content any) *Response
- func (c *Context) Service() *Service
- func (c *Context) ShouldBindJSON(stc any) *Response
- func (c *Context) StreamResponse(reader io.Reader, mime ...string) *Response
- func (c *Context) StringResponse(content string) *Response
- func (c *Context) Unmarshal(data []byte, v interface{}) error
- func (c *Context) UserSVC() UserService
- func (c *Context) Validate(stc any, ctx ...map[string]any) *Response
- func (c *Context) Validator() *validator.Validate
- type Ctx
- type DependencyFunc
- type Dict
- type DictIface
- type Event
- type EventKind
- type FastApi
- func (f *FastApi) APIRouters() []*Router
- func (f *FastApi) AcquireCtx(fctx *fiber.Ctx) *Context
- func (f *FastApi) ActivateHotSwitch() *FastApi
- func (f *FastApi) AddCronjob(jobs ...cronjob.CronJob) *FastApi
- func (f *FastApi) AddResponseHeader(key, value string) *FastApi
- func (f *FastApi) Delete(path string, handler HandlerFunc, opts ...Option) *Route
- func (f *FastApi) DeleteResponseHeader(key string) *FastApi
- func (f *FastApi) Description() string
- func (f *FastApi) DisableBaseRoutes() *FastApi
- func (f *FastApi) DisableRequestValidate() *FastApi
- func (f *FastApi) DisableResponseValidate() *FastApi
- func (f *FastApi) DisableSwagAutoCreate() *FastApi
- func (f *FastApi) DumpPID()
- func (f *FastApi) EnableDumpPID() *FastApi
- func (f *FastApi) EnableMultipleProcess() *FastApi
- func (f *FastApi) Engine() *fiber.App
- func (f *FastApi) Get(path string, handler HandlerFunc, opts ...Option) *Route
- func (f *FastApi) Host() string
- func (f *FastApi) IncludeRouter(router *Router) *FastApi
- func (f *FastApi) IsDebug() bool
- func (f *FastApi) OnEvent(kind EventKind, fc func()) *FastApi
- func (f *FastApi) OnShutdown(fc func()) *FastApi
- func (f *FastApi) OnStartup(fc func()) *FastApi
- func (f *FastApi) PID() int
- func (f *FastApi) Patch(path string, handler HandlerFunc, opts ...Option) *Route
- func (f *FastApi) Port() string
- func (f *FastApi) Post(path string, handler HandlerFunc, opts ...Option) *Route
- func (f *FastApi) Put(path string, handler HandlerFunc, opts ...Option) *Route
- func (f *FastApi) ReleaseCtx(ctx *Context)
- func (f *FastApi) ReplaceErrorHandler(fc fiber.ErrorHandler) *FastApi
- func (f *FastApi) ReplaceRecover(fc StackTraceHandlerFunc) *FastApi
- func (f *FastApi) ReplaceStackTraceHandler(fc StackTraceHandlerFunc) *FastApi
- func (f *FastApi) Run(host, port string)
- func (f *FastApi) Service() *Service
- func (f *FastApi) SetDescription(description string) *FastApi
- func (f *FastApi) SetLogger(logger logger.Iface) *FastApi
- func (f *FastApi) SetShutdownTimeout(timeout int) *FastApi
- func (f *FastApi) SetUserSVC(svc UserService) *FastApi
- func (f *FastApi) Shutdown()
- func (f *FastApi) ShutdownWithTimeout() time.Duration
- func (f *FastApi) Title() string
- func (f *FastApi) Use(middleware ...any) *FastApi
- func (f *FastApi) Version() string
- type Field
- type H
- type HTTPValidationError
- type HandlerFunc
- type M
- type MetaField
- type Metadata
- type Option
- type QueryModel
- type QueryParameter
- type Response
- type ResponseHeader
- type ResponseType
- type Route
- func (f *Route) AddD(fcs ...DependencyFunc) *Route
- func (f *Route) AddDependency(fcs ...DependencyFunc) *Route
- func (f *Route) Deprecate() *Route
- func (f *Route) LowerMethod() string
- func (f *Route) NewRequestModel() any
- func (f *Route) Path(prefix string) string
- func (f *Route) SetD(description string) *Route
- func (f *Route) SetDescription(description string) *Route
- func (f *Route) SetQ(m godantic.QueryParameter) *Route
- func (f *Route) SetQueryParams(m godantic.QueryParameter) *Route
- func (f *Route) SetReq(m godantic.SchemaIface) *Route
- func (f *Route) SetRequestModel(m godantic.SchemaIface) *Route
- type RouteMeta
- type RouteModelValidateHandlerFunc
- type Router
- func (f *Router) Activate() *Router
- func (f *Router) DELETE(path string, responseModel godantic.SchemaIface, summary string, ...) *Route
- func (f *Router) Delete(path string, handler HandlerFunc, opts ...Option) *Route
- func (f *Router) Deprecate() *Router
- func (f *Router) GET(path string, responseModel godantic.SchemaIface, summary string, ...) *Route
- func (f *Router) Get(path string, handler HandlerFunc, opts ...Option) *Route
- func (f *Router) IncludeRouter(router *Router) *Router
- func (f *Router) PATCH(path string, requestModel, responseModel godantic.SchemaIface, summary string, ...) *Route
- func (f *Router) POST(path string, requestModel, responseModel godantic.SchemaIface, summary string, ...) *Route
- func (f *Router) PUT(path string, requestModel, responseModel godantic.SchemaIface, summary string, ...) *Route
- func (f *Router) Patch(path string, handler HandlerFunc, opts ...Option) *Route
- func (f *Router) Post(path string, handler HandlerFunc, opts ...Option) *Route
- func (f *Router) Put(path string, handler HandlerFunc, opts ...Option) *Route
- func (f *Router) Routes() map[string]*Route
- type SchemaIface
- type Service
- type StackTraceHandlerFunc
- type UserService
- type ValidationError
Constants ¶
const ( ModelNotDefine = "Data model is undefined" ModelNotMatch = "Value type mismatch" ModelCannotString = "The return value cannot be a string" ModelCannotNumber = "The return value cannot be a number" ModelCannotInteger = "The return value cannot be a integer" ModelCannotBool = "The return value cannot be a boolean" ModelCannotArray = "The return value cannot be a array" PathPsIsEmpty = "Path must not be empty" QueryPsIsEmpty = "Query must not be empty" )
const ( Version = "0.1.4" Copyright = "chendemo12" Website = "https://github.com/Chendemo12" )
const ReminderWhenResponseModelIsNil = " `| 路由未明确定义返回值,文档处缺省为string类型,实际可以是任意类型`"
const RouteSeparator = "|_0#0_|"
RouteSeparator 路由分隔符,用于分割路由方法和路径
const WebsocketMethod = "WS"
Variables ¶
var ( Str = godantic.String String = godantic.String Bool = godantic.Bool Boolean = godantic.Bool Int = godantic.Int Byte = godantic.Uint8 Int8 = godantic.Int8 Int16 = godantic.Int16 Int32 = godantic.Int32 Int64 = godantic.Int64 Uint8 = godantic.Uint8 Uint16 = godantic.Uint16 Uint32 = godantic.Uint32 Uint64 = godantic.Uint64 Float = godantic.Float Float32 = godantic.Float32 Float64 = godantic.Float64 List = godantic.List Array = godantic.List Ints = godantic.List(godantic.Int) Bytes = godantic.List(godantic.Uint8) Strings = godantic.List(godantic.String) Floats = godantic.List(godantic.Float) )
var ( StructReflect = godantic.StructReflect QueryJsonName = godantic.QueryJsonName IsFieldRequired = godantic.IsFieldRequired ReflectObjectType = godantic.ReflectObjectType StringsToInts = godantic.StringsToInts StringsToFloats = godantic.StringsToFloats )
var (
F = helper.CombineStrings
)
Functions ¶
Types ¶
type BaseModelIface ¶
type Config ¶ added in v0.1.4
type Config struct { UserSvc UserService `json:"-" description:"自定义服务依赖"` Logger logger.Iface `json:"-" description:"日志"` ErrorHandler fiber.ErrorHandler `json:"-" description:"请求错误处理方法"` RecoverHandler StackTraceHandlerFunc `json:"-" description:"异常处理方法"` Version string `json:"version,omitempty" description:"APP版本号"` Description string `json:"description,omitempty" description:"APP描述"` Title string `json:"title,omitempty" description:"APP标题,也是日志文件名"` ShutdownTimeout int `json:"shutdown_timeout,omitempty" description:"平滑关机,单位秒"` DisableSwagAutoCreate bool `json:"disable_swag_auto_create,omitempty" description:"禁用自动文档"` EnableMultipleProcess bool `json:"enable_multiple_process,omitempty" description:"开启多进程"` EnableDumpPID bool `json:"enable_dump_pid,omitempty" description:"输出PID文件"` DisableResponseValidate bool `json:"disable_response_validate,omitempty" description:"禁用响应体自动序列化"` DisableRequestValidate bool `json:"disable_request_validate,omitempty" description:"禁用请求体自动校验"` DisableBaseRoutes bool `json:"disable_base_routes,omitempty" description:"禁用基础路由"` Debug bool `json:"debug,omitempty" description:"调试模式"` }
type Context ¶
type Context struct { PathFields map[string]string `json:"path_fields,omitempty"` // 路径参数 QueryFields map[string]string `json:"query_fields,omitempty"` // 查询参数 RequestBody any `json:"request_body,omitempty"` // 请求体,初始值为1 // contains filtered or unexported fields }
Context 路由上下文信息, 也是钩子函数的操作句柄
此结构体内包含了相应体 response 以减少在路由处理过程中的内存分配和复制
注意: 当一个路由被执行完毕时, 路由函数 HandlerFunc 中的 Context 将被立刻释放回收, 因此在return之后对
Context 的任何引用都是不对的, 若需在return之后监听 Context.DisposableCtx() 则应该显式的复制或派生
func (*Context) AdvancedResponse ¶
AdvancedResponse 高级返回值,允许返回一个函数,以实现任意类型的返回 (不校验返回值)
@param statusCode int 响应状态码 @param content fiber.Handler 钩子函数 @return resp *Response response返回体
func (*Context) AnyResponse ¶
AnyResponse 自定义响应体,响应体可是任意类型 (不校验返回值)
@param statusCode int 响应状态码 @param content any 响应体 @param contentType string 响应头MIME @return resp *Response response返回体
func (*Context) BodyParser ¶
BodyParser 序列化请求体
@param c *fiber.Ctx fiber上下文 @param a any 请求体指针 @return *Response 错误信息,若为nil 则序列化成功
func (*Context) DisposableCtx ¶
DisposableCtx 针对此次请求的唯一context, 当路由执行完毕返回时,将会自动关闭
@return context.Context 唯一context
func (*Context) Done ¶
func (c *Context) Done() <-chan struct{}
Done 监听 DisposableCtx 是否完成退出
@return chan struct{} 是否退出
func (*Context) EngineCtx ¶
func (c *Context) EngineCtx() *fiber.Ctx
EngineCtx 获取web引擎的上下文 Service
@return *fiber.Ctx fiber.App 的上下文信息
func (*Context) ErrorResponse ¶
ErrorResponse 返回一个服务器错误 (不校验返回值)
@param content any 错误消息 @return resp *Response response返回体
func (*Context) FileResponse ¶
FileResponse 返回值为文件对象,如:照片视频文件流等, 若文件不存在,则状态码置为404 (不校验返回值)
@param filepath string 文件路径 @return resp *Response response返回体
func (*Context) HTMLResponse ¶
HTMLResponse 返回一段HTML文本 (不校验返回值)
@param statusCode int 响应状态码 @param content string HTML文本字符串 @return resp *Response response返回体
func (*Context) JSONResponse ¶
JSONResponse 仅支持可以json序列化的响应体 (校验返回值)
对于结构体类型: 其返回值为序列化后的json 对于基本数据类型: 其返回值为实际数值 对于数组类型: 若其子元素为Uint8,则自动转换为 StreamResponse 以避免转义错误,但应显式的返回 StreamResponse
@param statusCode int 响应状态码 @param content any 可以json序列化的类型 @return resp *Response response返回体
func (*Context) OKResponse ¶
OKResponse 返回状态码为200的 JSONResponse (校验返回值)
@param content any 可以json序列化的类型 @return resp *Response response返回体
func (*Context) ShouldBindJSON ¶
ShouldBindJSON 绑定并校验参数是否正确
func (*Context) StreamResponse ¶
StreamResponse 返回值为字节流对象 (不校验返回值)
@param reader io.Reader 字节流 @param mime string 返回头媒体资源类型信息, 缺省则为 "text/plain" @return resp *Response response返回体
func (*Context) StringResponse ¶
StringResponse 返回值为字符串对象 (校验返回值)
@param content string 字符串文本 @return resp *Response response返回体
type DependencyFunc ¶ added in v0.1.4
type FastApi ¶
type FastApi struct {
// contains filtered or unexported fields
}
func NEW ¶ added in v0.1.4
func NEW(title, version string, debug bool, svc UserService) *FastApi
NEW 创建一个 FastApi 服务
@param title string Application name @param version string Version @param debug bool 是否开启调试模式 @param service UserService custom ServiceContext @return *FastApi fastapi对象
func (*FastApi) AcquireCtx ¶
AcquireCtx 申请一个 Context 并初始化
func (*FastApi) ActivateHotSwitch ¶
ActivateHotSwitch 创建一个热开关,监听信号量30,用来改变程序调试开关状态
func (*FastApi) AddCronjob ¶
AddCronjob 添加定时任务(循环调度任务) 此任务会在各种初始化及启动事件全部执行完成之后触发
func (*FastApi) AddResponseHeader ¶
AddResponseHeader 添加一个响应头
@param key string 键 @param value string 值
func (*FastApi) Delete ¶ added in v0.1.4
func (f *FastApi) Delete(path string, handler HandlerFunc, opts ...Option) *Route
Delete 请求
func (*FastApi) Description ¶
Description 描述信息,同时会显示在Swagger文档上
func (*FastApi) DisableBaseRoutes ¶
DisableBaseRoutes 禁用基础路由
func (*FastApi) DisableRequestValidate ¶
DisableRequestValidate 禁用请求体自动验证
func (*FastApi) DisableResponseValidate ¶
DisableResponseValidate 禁用返回体自动验证
func (*FastApi) DisableSwagAutoCreate ¶
DisableSwagAutoCreate 禁用文档自动生成
func (*FastApi) DumpPID ¶
func (f *FastApi) DumpPID()
DumpPID 存储PID, 文件权限为0775 对于 Windows 其文件为当前运行目录下的pid.txt; 对于 类unix系统,其文件为/run/{Title}.pid, 若无读写权限则改为当前运行目录下的pid.txt;
func (*FastApi) EnableMultipleProcess ¶ added in v0.1.4
EnableMultipleProcess 开启多进程
func (*FastApi) Engine ¶
func (f *FastApi) Engine() *fiber.App
Engine 获取fiber引擎
@return *fiber.App fiber引擎
func (*FastApi) Get ¶ added in v0.1.4
func (f *FastApi) Get(path string, handler HandlerFunc, opts ...Option) *Route
Get 请求
func (*FastApi) OnEvent ¶
OnEvent 添加事件
@param kind 事件类型,取值需为 "startup" / "shutdown" @param fs func() 事件
func (*FastApi) Patch ¶ added in v0.1.4
func (f *FastApi) Patch(path string, handler HandlerFunc, opts ...Option) *Route
Patch 请求
func (*FastApi) Post ¶ added in v0.1.4
func (f *FastApi) Post(path string, handler HandlerFunc, opts ...Option) *Route
Post 请求
func (*FastApi) Put ¶ added in v0.1.4
func (f *FastApi) Put(path string, handler HandlerFunc, opts ...Option) *Route
Put 请求
func (*FastApi) ReplaceErrorHandler ¶
ReplaceErrorHandler 替换fiber错误处理方法,是 请求错误处理方法
func (*FastApi) ReplaceRecover ¶
func (f *FastApi) ReplaceRecover(fc StackTraceHandlerFunc) *FastApi
ReplaceRecover 重写全局 recover 方法
func (*FastApi) ReplaceStackTraceHandler ¶
func (f *FastApi) ReplaceStackTraceHandler(fc StackTraceHandlerFunc) *FastApi
ReplaceStackTraceHandler 替换错误堆栈处理函数,即 recover 方法
func (*FastApi) Run ¶
Run 启动服务, 此方法会阻塞运行,因此必须放在main函数结尾 此方法已设置关闭事件和平滑关闭. 当 Interrupt 信号被触发时,首先会关闭 根Context,然后逐步执行“关机事件”,最后调用平滑关闭方法,关闭服务 启动前通过 SetShutdownTimeout 设置"平滑关闭异常时"的最大超时时间
func (*FastApi) SetShutdownTimeout ¶
SetShutdownTimeout 修改关机前最大等待时间
@param timeout in 修改关机前最大等待时间, 单位秒
func (*FastApi) SetUserSVC ¶
func (f *FastApi) SetUserSVC(svc UserService) *FastApi
SetUserSVC 设置一个自定义服务依赖
@param service UserService 服务依赖
func (*FastApi) ShutdownWithTimeout ¶
ShutdownWithTimeout 关机前最大等待时间
type HTTPValidationError ¶
type HTTPValidationError = godantic.HTTPValidationError
type Option ¶ added in v0.1.1
type Option struct { Summary string `json:"summary" description:"摘要描述"` ResponseModel godantic.SchemaIface `json:"response_model" description:"响应体模型"` RequestModel godantic.SchemaIface `json:"request_model" description:"请求体模型"` Params godantic.QueryParameter `json:"params" description:"查询参数,结构体"` Description string `json:"description" description:"路由描述"` Tags []string `json:"tags" description:"路由标签"` Dependencies []DependencyFunc `json:"-" description:"依赖"` Handlers []HandlerFunc `json:"-" description:"处理函数"` Deprecated bool `json:"deprecated" description:"是否禁用"` }
type QueryModel ¶
type QueryModel = godantic.QueryModel
type QueryParameter ¶
type QueryParameter = godantic.QueryParameter
type Response ¶
type Response struct { Content any `json:"content"` // 响应体 ContentType string `json:"contentType"` // 响应类型,默认为 application/json Type ResponseType `json:"type"` // 返回体类型 StatusCode int `json:"status_code"` // 响应状态码 }
Response 路由返回值
type ResponseHeader ¶
type ResponseHeader struct { Key string `json:"key" Description:"Key" binding:"required"` Value string `json:"value" Description:"Value" binding:"required"` }
ResponseHeader 自定义响应头
type ResponseType ¶
type ResponseType int
const ( CustomResponseType ResponseType = iota + 1 JsonResponseType StringResponseType StreamResponseType FileResponseType ErrResponseType HtmlResponseType AdvancedResponseType )
type Route ¶
type Route struct { ResponseModel *godantic.Metadata `description:"响应体元数据"` RequestModel *godantic.Metadata `description:"请求体元数据"` Description string `json:"description" description:"详细描述"` Summary string `json:"summary" description:"摘要描述"` Method string `json:"method" description:"请求方法"` RelativePath string `json:"relative_path" description:"相对路由"` Tags []string `json:"tags" description:"路由标签"` QueryFields []*godantic.QModel `json:"-" description:"查询参数"` Handlers []fiber.Handler `json:"-" description:"处理函数"` Dependencies []DependencyFunc `json:"-" description:"依赖"` PathFields []*godantic.QModel `json:"-" description:"路径参数"` // contains filtered or unexported fields }
Route 一个完整的路由对象,此对象会在程序启动时生成swagger文档 其中相对路径Path不能重复,否则后者会覆盖前者
func (*Route) AddD ¶
func (f *Route) AddD(fcs ...DependencyFunc) *Route
AddD 添加依赖项,用于在执行路由函数前执行一个自定义操作,此操作作用于参数校验通过之后
@param fcs DependencyFunc 依赖项
func (*Route) AddDependency ¶
func (f *Route) AddDependency(fcs ...DependencyFunc) *Route
AddDependency 添加依赖项,用于在执行路由函数前执行一个自定义操作,此操作作用于参数校验通过之后
@param fcs DependencyFunc 依赖项
func (*Route) LowerMethod ¶
func (*Route) SetQ ¶
func (f *Route) SetQ(m godantic.QueryParameter) *Route
SetQ 设置查询参数,此空struct的每一个字段都将作为一个单独的查询参数 且此结构体的任意字段有且仅支持 string 类型
@param m godantic.QueryParameter 查询参数对象,
func (*Route) SetQueryParams ¶
func (f *Route) SetQueryParams(m godantic.QueryParameter) *Route
SetQueryParams 设置查询参数,此空struct的每一个字段都将作为一个单独的查询参数 且此结构体的任意字段有且仅支持 string 类型
@param m godantic.QueryParameter 查询参数对象,
func (*Route) SetReq ¶
func (f *Route) SetReq(m godantic.SchemaIface) *Route
SetReq 设置请求体对象
@param m any 请求体对象
func (*Route) SetRequestModel ¶
func (f *Route) SetRequestModel(m godantic.SchemaIface) *Route
SetRequestModel 设置请求体对象,此model应为一个空struct实例,而非指针类型,且仅"GET",http.MethodDelete有效
@param m any 请求体对象
type RouteMeta ¶
type RouteMeta struct { Get *Route Post *Route Patch *Route Delete *Route Put *Route Any *Route Path string `json:"path" description:"绝对路由"` }
RouteMeta 记录创建的路由对象,用于其后的请求和响应校验
type RouteModelValidateHandlerFunc ¶ added in v0.1.1
RouteModelValidateHandlerFunc 返回值校验方法
@param resp any 响应体 @param meta *godantic.Metadata 模型元数据 @return *Response 响应体
type Router ¶
Router 一个独立的路由组,Prefix路由组前缀,其内部的子路由均包含此前缀
func (*Router) DELETE ¶
func (f *Router) DELETE( path string, responseModel godantic.SchemaIface, summary string, handler HandlerFunc, ) *Route
DELETE http delete method
@param path string 相对路径,必须以"/"开头 @param summary string 路由摘要信息 @param responseModel godantic.SchemaIface 响应体对象, 此model应为一个空struct实例,而非指针类型 @param handler []HandlerFunc 路由处理方法 @param addition any 附加参数
func (*Router) Delete ¶ added in v0.1.4
func (f *Router) Delete(path string, handler HandlerFunc, opts ...Option) *Route
func (*Router) GET ¶
func (f *Router) GET( path string, responseModel godantic.SchemaIface, summary string, handler HandlerFunc, ) *Route
GET http get method
@param path string 相对路径,必须以"/"开头 @param summary string 路由摘要信息 @param queryModel godantic.QueryParameter 查询参数,仅支持struct类型 @param responseModel godantic.SchemaIface 响应体对象, 此model应为一个空struct实例,而非指针类型 @param handler []HandlerFunc 路由处理方法 @param addition any 附加参数,如:"deprecated"用于禁用此路由
func (*Router) Get ¶ added in v0.1.4
func (f *Router) Get(path string, handler HandlerFunc, opts ...Option) *Route
func (*Router) PATCH ¶
func (f *Router) PATCH( path string, requestModel, responseModel godantic.SchemaIface, summary string, handler HandlerFunc, ) *Route
PATCH http patch method
func (*Router) POST ¶
func (f *Router) POST( path string, requestModel, responseModel godantic.SchemaIface, summary string, handler HandlerFunc, ) *Route
POST http post method
@param path string 相对路径,必须以"/"开头 @param summary string 路由摘要信息 @param requestModel godantic.SchemaIface 请求体对象, 此model应为一个空struct实例,而非指针类型 @param responseModel godantic.SchemaIface 响应体对象, 此model应为一个空struct实例,而非指针类型 @param handler []HandlerFunc 路由处理方法 @param addition any 附加参数,如:"deprecated"用于禁用此路由
func (*Router) PUT ¶
func (f *Router) PUT( path string, requestModel, responseModel godantic.SchemaIface, summary string, handler HandlerFunc, ) *Route
PUT http put method
func (*Router) Patch ¶ added in v0.1.4
func (f *Router) Patch(path string, handler HandlerFunc, opts ...Option) *Route
func (*Router) Post ¶ added in v0.1.4
func (f *Router) Post(path string, handler HandlerFunc, opts ...Option) *Route
type SchemaIface ¶
type SchemaIface = godantic.SchemaIface
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service FastApi 全局服务依赖信息 此对象由FastApi启动时自动创建,此对象不应被修改,组合和嵌入, 但可通过 setUserSVC 接口设置自定义的上下文信息,并在每一个路由钩子函数中可得
type StackTraceHandlerFunc ¶
type StackTraceHandlerFunc = func(c *fiber.Ctx, e any)
StackTraceHandlerFunc 错误堆栈处理函数, 即 recover 方法
type ValidationError ¶
type ValidationError = godantic.ValidationError