Documentation
¶
Index ¶
- func GetKeyCommonHandler(ns ...string) string
- func GetKeyExampleHandler(ns ...string) string
- func GetKeyHealthHandler(ns ...string) string
- func RegisterRouteHandlers(ctx frame.ContextFramer, app fiber.Router)
- type CommonHandler
- type ExampleHandler
- func (h *ExampleHandler) CreateExample(c *fiber.Ctx) error
- func (h *ExampleHandler) GetExample(c *fiber.Ctx) error
- func (h *ExampleHandler) GetExampleWithTaskDispatcher(c *fiber.Ctx) error
- func (h *ExampleHandler) GetExamples(c *fiber.Ctx) error
- func (h *ExampleHandler) HelloWorld(c *fiber.Ctx) error
- type HealthHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetKeyCommonHandler ¶
GetKeyCommonHandler 获取 CommonHandler 注册到全局管理器的实例key
func GetKeyExampleHandler ¶
GetKeyExampleHandler 定义和获取 ExampleHandler 注册到全局管理器的实例key
func GetKeyHealthHandler ¶
func RegisterRouteHandlers ¶
func RegisterRouteHandlers(ctx frame.ContextFramer, app fiber.Router)
Types ¶
type CommonHandler ¶
type CommonHandler struct {
frame.ApiLocator // 继承frame.ApiLocator
KeyTestService string // 定义依赖组件的全局管理器的实例key。通过key即可由 h.GetInstance(key) 方法获取实例,或由 frame.GetMustInstance[T](key) 泛型方法获取实例,无需wire或其他依赖注入工具
}
CommonHandler 示例公共处理器,继承自 frame.ApiLocator,具备获取上下文、配置、日志、注册实例等功能
func NewCommonHandler ¶
func NewCommonHandler(ctx frame.ContextFramer) *CommonHandler
NewCommonHandler 直接New,无需依赖注入(Wire) TestService对象,内部依赖走全局管理器延迟获取依赖组件
func (*CommonHandler) TestGetInstance ¶
func (h *CommonHandler) TestGetInstance(c *fiber.Ctx) error
TestGetInstance 测试获取注册实例,通过 h.GetInstance(key) 方法获取TestService注册实例,无需编译阶段的wire依赖注入
func (*CommonHandler) TestGetMustInstance ¶
func (h *CommonHandler) TestGetMustInstance(c *fiber.Ctx) error
TestGetMustInstance 测试获取注册实例,通过 frame.GetMustInstance[T](key) 泛型方法获取注册实例,无需编译阶段的wire依赖注入
func (*CommonHandler) TestGetMustInstanceFailed ¶
func (h *CommonHandler) TestGetMustInstanceFailed(c *fiber.Ctx) error
TestGetMustInstanceFailed 测试获取注册实例失败,通过 frame.GetMustInstance[T](key) 泛型方法获取注册实例,无需编译阶段的wire依赖注入
type ExampleHandler ¶
type ExampleHandler struct {
frame.ApiLocator
Service *service.ExampleService // 直接定义依赖的组件指针类型成员变量,由wire注入,无需注册到全局管理器
KeyTestService string // 定义依赖组件的全局管理器的实例key。通过key即可由 h.GetInstance(key) 方法获取实例,或由 frame.GetMustInstance[T](key) 泛型方法获取实例,无需wire或其他依赖注入工具
}
ExampleHandler 示例处理器,继承自 frame.ApiLocator,具备获取上下文、配置、日志、注册实例等功能
func InjectExampleApi ¶
func InjectExampleApi(ctx frame.ContextFramer) (*ExampleHandler, error)
func NewExampleHandler ¶
func NewExampleHandler(ctx frame.ContextFramer, es *service.ExampleService) *ExampleHandler
func (*ExampleHandler) CreateExample ¶
func (h *ExampleHandler) CreateExample(c *fiber.Ctx) error
CreateExample godoc
@Summary create A Example
@Description create a new Example Object
@Tags example
@Accept json
@Produce json
@Param example body requestvo.ExampleReqVo true "Example Request"
@Success 200 {object} response.RespInfo
@Failure 400 {object} response.RespInfo
@Failure 422 {object} response.RespInfo
@Failure 500 {object} response.RespInfo
@Router /create [post]
func (*ExampleHandler) GetExample ¶
func (h *ExampleHandler) GetExample(c *fiber.Ctx) error
GetExample godoc
@Summary get A Example
@Description get Example Object by ID
@Tags example
@Accept json
@Produce json
@Param id path string true "Example ID"
@Success 200 {object} response.RespInfo
@Failure 400 {object} response.RespInfo
@Failure 404 {object} response.RespInfo
@Failure 500 {object} response.RespInfo
@Router /example/get/{id} [get]
func (*ExampleHandler) GetExampleWithTaskDispatcher ¶
func (h *ExampleHandler) GetExampleWithTaskDispatcher(c *fiber.Ctx) error
GetExampleWithTaskDispatcher godoc
@Summary get A Example with Dispatcher Task
@Description get Example Object by ID, on Dispatcher a task to do something
@Tags example
@Accept json
@Produce json
@Param id path string true "Example ID"
@Success 200 {object} response.RespInfo
@Failure 400 {object} response.RespInfo
@Failure 404 {object} response.RespInfo
@Failure 500 {object} response.RespInfo
@Router /example/on-async-task/get/{id} [get]
func (*ExampleHandler) GetExamples ¶
func (h *ExampleHandler) GetExamples(c *fiber.Ctx) error
GetExamples godoc
@Summary get Examples with pagination
@Description get paginated list of Example objects
@Tags example
@Accept json
@Produce json
@Param p query int false "Page number" default(1) minimum(1)
@Param s query int false "Page size" default(10) minimum(1) maximum(20)
@Success 200 {object} response.RespInfo
@Failure 400 {object} response.RespInfo
@Failure 422 {object} response.RespInfo
@Failure 500 {object} response.RespInfo
@Router /list [get]
func (*ExampleHandler) HelloWorld ¶
func (h *ExampleHandler) HelloWorld(c *fiber.Ctx) error
GetTest 测试接口,通过 h.GetInstance(key) 方法获取TestService注册实例,无需编译阶段的wire依赖注入
type HealthHandler ¶
type HealthHandler struct {
frame.ApiLocator
Service *service.HealthService
}
func InjectHealthApi ¶
func InjectHealthApi(ctx frame.ContextFramer) (*HealthHandler, error)
func NewHealthHandler ¶
func NewHealthHandler(ctx frame.ContextFramer, serv *service.HealthService) *HealthHandler