Documentation
¶
Overview ¶
Package apitoken implements CRUD HTTP endpoints for shared API tokens. It is intentionally free of any internal/server import — all error responses are written inline so the package has no circular dependency.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterRoutes ¶
func RegisterRoutes(group *swagger.RouteGroup, h *Handler)
RegisterRoutes wires all token management endpoints onto the given group.
Types ¶
type APITokenInfo ¶
type APITokenInfo struct {
TokenID string `json:"token_id"`
UserID string `json:"user_id"`
DisplayName string `json:"display_name"`
Enabled bool `json:"enabled"`
LastUsedAt *time.Time `json:"last_used_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
CreatedBy string `json:"created_by,omitempty"`
}
APITokenInfo represents token metadata (without the raw token string).
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles API-token HTTP requests.
func NewHandler ¶
func NewHandler(store *db.APITokenStore) *Handler
NewHandler creates a Handler backed by the given store.
func (*Handler) Regenerate ¶
Regenerate handles POST /tokens/:token_id/regenerate — keeps the same token_id but issues a new token string.
type TokenCreateRequest ¶
type TokenCreateRequest struct {
DisplayName string `json:"display_name" binding:"required"`
}
TokenCreateRequest is the request body for creating a new API token.
type TokenCreateResponse ¶
type TokenCreateResponse struct {
Token string `json:"token"`
TokenID string `json:"token_id"`
UserID string `json:"user_id"`
DisplayName string `json:"display_name"`
CreatedAt time.Time `json:"created_at"`
}
TokenCreateResponse is returned after a token is created or regenerated.
type TokenListQuery ¶ added in v0.260716.1
type TokenListQuery struct {
UserID string `form:"user_id" json:"user_id,omitempty"`
Enabled *bool `form:"enabled" json:"enabled,omitempty"`
Limit int `form:"limit" json:"limit,omitempty"`
Offset int `form:"offset" json:"offset,omitempty"`
}
TokenListQuery describes the optional filters accepted by GET /tokens.
type TokenListResponse ¶
type TokenListResponse struct {
Tokens []APITokenInfo `json:"tokens"`
Total int64 `json:"total"`
}
TokenListResponse is the response for listing tokens.