Documentation ¶
Index ¶
- Constants
- Variables
- func Register(router gin.IRouter, root string, endpoints HandlerMap) *gin.RouterGroup
- func SupplyController(c Controller) fx.Option
- type Controller
- type DelayInjectorController
- type FaultInjectorController
- type HandlerMap
- type KillController
- type LogController
- type UptimeController
Constants ¶
const ControllersTag = `group:"controllers"`
const MethodAny = "any"
MethodAny is a special value to pass for the Method key in a HandlerMap to call RouterGroup.Any instead of RouterGroup.METHOD. It is chosen so that it cannot overlap with any valid HTTP method.
Variables ¶
var Module = fx.Module( "controllers", fx.Provide(fx.Annotate( func(readies []services.ReadyCheck) *UptimeController { return &UptimeController{readies: readies} }, fx.ParamTags(services.ReadyTag), fx.As(new(Controller)), fx.ResultTags(ControllersTag), )), SupplyController(&LogController{}), fx.Provide(fx.Annotate( func(shutdowner fx.Shutdowner) *KillController { return &KillController{shutdowner: shutdowner} }, fx.As(new(Controller)), fx.ResultTags(ControllersTag), )), SupplyController(&DelayInjectorController{}), fx.Provide(fx.Annotate( func(faults *faults.Set) *FaultInjectorController { return &FaultInjectorController{ faults: faults, } }, fx.As(new(Controller)), fx.ResultTags(ControllersTag), )), )
Functions ¶
func Register ¶ added in v0.13.0
func Register(router gin.IRouter, root string, endpoints HandlerMap) *gin.RouterGroup
RegisterMap is a helper for making many calls to RouterGroup.METHOD(...), using a table-driven approach. As a special case, if the Method in a map entry is "any", it will call RouterGroup.Any instead of a method-specific handler. As another special case, `nil` handlers will be replaced with a default handler that returns HTTP 501 Not Implemented.
func SupplyController ¶ added in v0.13.0
func SupplyController(c Controller) fx.Option
Types ¶
type Controller ¶ added in v0.13.0
Controller defines the interface for a controller that can register its routes against a (gin) router.
type DelayInjectorController ¶ added in v0.8.0
type DelayInjectorController struct {
// contains filtered or unexported fields
}
func (*DelayInjectorController) DeleteDelay ¶ added in v0.8.0
func (cc *DelayInjectorController) DeleteDelay(c *gin.Context)
func (*DelayInjectorController) GetDelay ¶ added in v0.8.0
func (cc *DelayInjectorController) GetDelay(c *gin.Context)
func (*DelayInjectorController) PutDelay ¶ added in v0.8.0
func (cc *DelayInjectorController) PutDelay(c *gin.Context)
type FaultInjectorController ¶
type FaultInjectorController struct {
// contains filtered or unexported fields
}
func (*FaultInjectorController) AddDescriptor ¶
func (f *FaultInjectorController) AddDescriptor(c *gin.Context)
func (*FaultInjectorController) GetDescriptors ¶
func (f *FaultInjectorController) GetDescriptors(c *gin.Context)
type HandlerMap ¶ added in v0.13.0
type HandlerMap = map[struct{ Method, Path string }]gin.HandlerFunc
HandlerMap defines a mapping from pairs of (method, path) to a handler function for a route. It is used in RegisterMap for a controller to add its routes in a table-driven format.
type KillController ¶ added in v0.13.0
type KillController struct {
// contains filtered or unexported fields
}
func (*KillController) HandleKill ¶ added in v0.13.0
func (k *KillController) HandleKill(c *gin.Context)
func (*KillController) HandleShutdown ¶ added in v0.13.0
func (k *KillController) HandleShutdown(c *gin.Context)
type LogController ¶ added in v0.13.0
type LogController struct { }
func (*LogController) GetLevels ¶ added in v0.13.0
func (*LogController) GetLevels(c *gin.Context)
func (*LogController) Register ¶ added in v0.13.0
func (lc *LogController) Register(router gin.IRouter) error
func (*LogController) SetComponentLevel ¶ added in v0.13.0
func (lc *LogController) SetComponentLevel(c *gin.Context)
type UptimeController ¶ added in v0.13.0
type UptimeController struct {
// contains filtered or unexported fields
}
func (*UptimeController) Handle ¶ added in v0.13.0
func (u *UptimeController) Handle(c *gin.Context)
func (*UptimeController) HandleSlow ¶ added in v0.13.0
func (u *UptimeController) HandleSlow(c *gin.Context)