Documentation
¶
Index ¶
- type CreateBindingRequest
- type CreateRequest
- type Handler
- func (h *Handler) Create(c *app.Context, req CreateRequest) (api.Created[models.RequestLimiter], error)
- func (h *Handler) CreateBinding(c *app.Context, req CreateBindingRequest) (api.Created[models.LimiterBinding], error)
- func (h *Handler) Delete(c *app.Context, req api.IDPathRequest) (api.StatusResponse, error)
- func (h *Handler) DeleteBinding(c *app.Context, req api.IDPathRequest) (api.StatusResponse, error)
- func (h *Handler) List(c *app.Context, req ListRequest) (api.PaginatedResponse[models.RequestLimiter], error)
- func (h *Handler) ListBindings(c *app.Context, req ListBindingsRequest) ([]models.LimiterBinding, error)
- func (h *Handler) Update(c *app.Context, req UpdateRequest) (models.RequestLimiter, error)
- type ListBindingsRequest
- type ListRequest
- type UpdateRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateBindingRequest ¶
type CreateBindingRequest struct {
LimiterID uint `json:"limiter_id" binding:"required"`
TargetType string `json:"target_type" binding:"required"`
TargetID uint `json:"target_id"` // global 时为 0
Enabled bool `json:"enabled"`
}
CreateBindingRequest 给某 limiter 加一条绑定。
type CreateRequest ¶
type CreateRequest struct {
Name string `json:"name" binding:"required"`
Enabled bool `json:"enabled"`
Metric string `json:"metric" binding:"required"`
Capacity int64 `json:"capacity"`
WindowMs int `json:"window_ms"`
KeyBy string `json:"key_by" binding:"required"`
ChannelScope string `json:"channel_scope"`
Action string `json:"action"`
QueueSize int `json:"queue_size"`
QueueTimeMs int `json:"queue_time_ms"`
Priority int `json:"priority"`
}
CreateRequest 是新建一条 limiter 策略的入参(绑定另走 binding 接口)。
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) Create ¶
func (h *Handler) Create(c *app.Context, req CreateRequest) (api.Created[models.RequestLimiter], error)
func (*Handler) CreateBinding ¶
func (h *Handler) CreateBinding(c *app.Context, req CreateBindingRequest) (api.Created[models.LimiterBinding], error)
func (*Handler) Delete ¶
func (h *Handler) Delete(c *app.Context, req api.IDPathRequest) (api.StatusResponse, error)
func (*Handler) DeleteBinding ¶
func (h *Handler) DeleteBinding(c *app.Context, req api.IDPathRequest) (api.StatusResponse, error)
func (*Handler) List ¶
func (h *Handler) List(c *app.Context, req ListRequest) (api.PaginatedResponse[models.RequestLimiter], error)
func (*Handler) ListBindings ¶
func (h *Handler) ListBindings(c *app.Context, req ListBindingsRequest) ([]models.LimiterBinding, error)
func (*Handler) Update ¶
func (h *Handler) Update(c *app.Context, req UpdateRequest) (models.RequestLimiter, error)
type ListBindingsRequest ¶
type ListBindingsRequest struct {
LimiterID string `form:"limiter_id" binding:"required"`
}
ListBindingsRequest 列出某 limiter 的绑定(limiter_id 必填)。
type ListRequest ¶
type ListRequest struct {
api.PaginationQuery
}
type UpdateRequest ¶
type UpdateRequest struct {
ID string `uri:"id" binding:"required"`
Fields map[string]any `json:"-"`
}
func (*UpdateRequest) SetBodyMap ¶
func (r *UpdateRequest) SetBodyMap(fields map[string]any)
Click to show internal directories.
Click to hide internal directories.