Documentation ¶
Index ¶
- func Bind[O any](binder *Binder, item *BindItem[O], middlewares ...api.Handler)
- func DeleteBind[O any](binder *Binder, item *SimpleBindItem[O], middlewares ...api.Handler)
- func GetBind[O any](binder *Binder, item *SimpleBindItem[O], middlewares ...api.Handler)
- func PostBind[O any](binder *Binder, item *SimpleBindItem[O], middlewares ...api.Handler)
- func PutBind[O any](binder *Binder, item *SimpleBindItem[O], middlewares ...api.Handler)
- func Static(binder *Binder, item *StaticBindItem)
- func StaticFile(binder *Binder, item *StaticFileBindItem)
- type BindItem
- type Binder
- type FormDomainObjectsFunc
- type RequestParamsBindFunc
- type ResponseFunc
- type ServiceFunc
- type SimpleBindItem
- type StaticBindItem
- type StaticFileBindItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteBind ¶
func DeleteBind[O any](binder *Binder, item *SimpleBindItem[O], middlewares ...api.Handler)
func GetBind ¶
func GetBind[O any](binder *Binder, item *SimpleBindItem[O], middlewares ...api.Handler)
func PostBind ¶
func PostBind[O any](binder *Binder, item *SimpleBindItem[O], middlewares ...api.Handler)
func PutBind ¶
func PutBind[O any](binder *Binder, item *SimpleBindItem[O], middlewares ...api.Handler)
func Static ¶
func Static(binder *Binder, item *StaticBindItem)
func StaticFile ¶
func StaticFile(binder *Binder, item *StaticFileBindItem)
Types ¶
type BindItem ¶
type BindItem[O any] struct { Method string *SimpleBindItem[O] }
BindItem 通用BindItem
type Binder ¶
type Binder struct {
// contains filtered or unexported fields
}
func NewBinder ¶
func NewBinder(router api.Router, i *infrastructure.Infrastructure) *Binder
type FormDomainObjectsFunc ¶
type RequestParamsBindFunc ¶
type ResponseFunc ¶
type ServiceFunc ¶
type ServiceFunc[O any] func(c *api.Context, params request.Params, objects []domain.Object, i *infrastructure.Infrastructure) (O, error)
type SimpleBindItem ¶
type SimpleBindItem[O any] struct { // URL相对路径 Path string // 响应泛型函数,如果不响应,需要使用NoResponse零值占位 ResponseFunc ResponseFunc[O] // 使用的请求参数,非必传,当请求参数为nil时,说明该接口没有参数 RequestParams request.Params // 可选的请求参数绑定函数 // 非必传,POST和PUT请求默认为JsonBody,DELETE和GET默认为QueryParams // 额外还提供了一些转化函数: // PathParams: 绑定路径参数 // MultipartForm: 绑定multipart form // FormBody: 绑定form body // XMLBody: 绑定XML body RequestParamsBindFunc RequestParamsBindFunc // 通过请求参数构造使用的领域对象,之后在ServiceFunc中会按照构造实体的顺序进行回调 // 非必传,如果为nil,则说明没有领域对象 // 与Objects字段二选一使用,如果都指定,会按照该字段处理 FormDomainObjectsFunc FormDomainObjectsFunc // 使用的领域对象,当使用Tag对实体进行标注后,可以直接通过该字段给定实体,之后在ServiceFunc中会按照给定实体的顺序进行回调 // 非必传,如果为nil或长度为0,则说明没有领域对象 // 与FormObjectsFunc字段二选一使用,如果都指定,会按照FormObjectsFunc字段处理 Objects []domain.Object // 应用服务泛型函数 ServiceFunc ServiceFunc[O] }
SimpleBindItem 简化的BindItem
type StaticBindItem ¶
StaticBindItem 静态路由item
type StaticFileBindItem ¶
Click to show internal directories.
Click to hide internal directories.