Documentation
¶
Index ¶
- Constants
- type AdminHandler
- func (h *AdminHandler) AddUserPermission(ctx *gin.Context)
- func (h *AdminHandler) CreatePermission(ctx *gin.Context)
- func (h *AdminHandler) CreateRateLimit(ctx *gin.Context)
- func (h *AdminHandler) DeletePermission(ctx *gin.Context)
- func (h *AdminHandler) DeleteRateLimit(ctx *gin.Context)
- func (h *AdminHandler) GetUser(ctx *gin.Context)
- func (h *AdminHandler) GetUserApplications(ctx *gin.Context)
- func (h *AdminHandler) ListPermissions(ctx *gin.Context)
- func (h *AdminHandler) ListRateLimits(ctx *gin.Context)
- func (h *AdminHandler) ListUsers(ctx *gin.Context)
- func (h *AdminHandler) RemoveUserPermission(ctx *gin.Context)
- func (h *AdminHandler) SetPermissionDefault(ctx *gin.Context)
- func (h *AdminHandler) UpdatePermission(ctx *gin.Context)
- func (h *AdminHandler) UpdateRateLimit(ctx *gin.Context)
- func (h *AdminHandler) UpdateUser(ctx *gin.Context)
- type ApplicationHandler
- type ConfigHandler
- type Handler
- type HandlerOption
- type UserHandler
Constants ¶
const ( DefaultPageLimit = datastore.DefaultPageLimit ErrMsgDatastore = "datastore is required" ErrMsgAuth = "auth service is required" ErrMsgUnauth = "Unauthorized" ErrMsgLimiter = "rate limiter is required" )
Constants for pagination and error messages
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdminHandler ¶
type AdminHandler struct {
*Handler
}
AdminHandler handles HTTP requests for admin operations.
func NewAdminHandler ¶
func NewAdminHandler(options ...HandlerOption) (*AdminHandler, error)
NewAdminHandler creates a new AdminHandler with the provided options.
func (*AdminHandler) AddUserPermission ¶
func (h *AdminHandler) AddUserPermission(ctx *gin.Context)
AddUserPermission grants a permission to a user
func (*AdminHandler) CreatePermission ¶
func (h *AdminHandler) CreatePermission(ctx *gin.Context)
CreatePermission creates a new permission
func (*AdminHandler) CreateRateLimit ¶
func (h *AdminHandler) CreateRateLimit(ctx *gin.Context)
CreateRateLimit creates a new rate limit class
func (*AdminHandler) DeletePermission ¶
func (h *AdminHandler) DeletePermission(ctx *gin.Context)
DeletePermission deletes a permission by ID
func (*AdminHandler) DeleteRateLimit ¶
func (h *AdminHandler) DeleteRateLimit(ctx *gin.Context)
DeleteRateLimit deletes a rate limit class by ID
func (*AdminHandler) GetUser ¶
func (h *AdminHandler) GetUser(ctx *gin.Context)
GetUser returns a single user by ID including their rate limit status
func (*AdminHandler) GetUserApplications ¶
func (h *AdminHandler) GetUserApplications(ctx *gin.Context)
GetUserApplications returns all applications for a given user
func (*AdminHandler) ListPermissions ¶
func (h *AdminHandler) ListPermissions(ctx *gin.Context)
ListPermissions returns all permissions
func (*AdminHandler) ListRateLimits ¶
func (h *AdminHandler) ListRateLimits(ctx *gin.Context)
ListRateLimits returns all rate limit classes
func (*AdminHandler) ListUsers ¶
func (h *AdminHandler) ListUsers(ctx *gin.Context)
ListUsers returns a paginated list of all users, or searches by username/ID if ?q= is provided
func (*AdminHandler) RemoveUserPermission ¶
func (h *AdminHandler) RemoveUserPermission(ctx *gin.Context)
RemoveUserPermission revokes a permission from a user
func (*AdminHandler) SetPermissionDefault ¶
func (h *AdminHandler) SetPermissionDefault(ctx *gin.Context)
SetPermissionDefault updates the default status of a permission
func (*AdminHandler) UpdatePermission ¶
func (h *AdminHandler) UpdatePermission(ctx *gin.Context)
UpdatePermission updates an existing permission
func (*AdminHandler) UpdateRateLimit ¶
func (h *AdminHandler) UpdateRateLimit(ctx *gin.Context)
UpdateRateLimit updates an existing rate limit class
func (*AdminHandler) UpdateUser ¶
func (h *AdminHandler) UpdateUser(ctx *gin.Context)
UpdateUser updates a user's active status and rate limit class
type ApplicationHandler ¶
type ApplicationHandler struct {
*Handler
}
ApplicationHandler handles HTTP requests related to applications.
func NewApplicationHandler ¶
func NewApplicationHandler(options ...HandlerOption) (*ApplicationHandler, error)
NewApplicationHandler creates a new ApplicationHandler with the provided options. It requires both a datastore and an authentication service to function properly.
func (*ApplicationHandler) CreateApplication ¶
func (h *ApplicationHandler) CreateApplication(ctx *gin.Context)
CreateApplication creates a new application for the currently logged-in user respecting their rate limit for maximum number of applications
func (*ApplicationHandler) DeleteApplication ¶
func (h *ApplicationHandler) DeleteApplication(ctx *gin.Context)
DeleteApplication deletes an application owned by the currently logged-in user
func (*ApplicationHandler) GetMyApplications ¶
func (h *ApplicationHandler) GetMyApplications(ctx *gin.Context)
GetMyApplications returns all applications for the currently logged-in user
func (*ApplicationHandler) UpdateApplication ¶
func (h *ApplicationHandler) UpdateApplication(ctx *gin.Context)
UpdateApplication updates an existing application belonging to the currently logged-in user
type ConfigHandler ¶
type ConfigHandler struct {
*Handler
}
ConfigHandler handles HTTP requests related to config.
func NewConfigHandler ¶
func NewConfigHandler(options ...HandlerOption) (*ConfigHandler, error)
NewConfigHandler creates a new ConfigHandler with the provided options. It requires both a datastore and an authentication service to function properly.
func (*ConfigHandler) GetConfig ¶
func (h *ConfigHandler) GetConfig(ctx *gin.Context)
type Handler ¶
Handler is a base handler that provides common functionality for all HTTP handlers.
func NewHandler ¶
func NewHandler(options ...HandlerOption) (*Handler, error)
NewHandler creates a new Handler with the provided options. It requires both a datastore and an authentication service to function properly.
func (*Handler) GetAuthenticatedUser ¶
GetAuthenticatedUser retrieves the authenticated user from the context
func (*Handler) RespondWithData ¶
func (h *Handler) RespondWithData(ctx *gin.Context, data interface{}, pagination *datastore.CursorPagination)
RespondWithData sends a JSON success response with the given data
type HandlerOption ¶
type HandlerOption func(*Handler)
HandlerOption defines a functional option for configuring a Handler
func WithAuthService ¶
func WithAuthService(auth *authz.Service) HandlerOption
WithAuthService sets the authentication service for the Handler
func WithDatastore ¶
func WithDatastore(store datastore.Datastore) HandlerOption
WithDatastore sets the datastore for the Handler
func WithRatelimiter ¶
func WithRatelimiter(limiter *ratelimit.RateLimit) HandlerOption
WithRatelimiter sets the rate limiter for the Handler
type UserHandler ¶
type UserHandler struct {
*Handler
}
UserHandler handles HTTP requests related to users.
func NewUserHandler ¶
func NewUserHandler(options ...HandlerOption) (*UserHandler, error)
NewUserHandler creates a new UserHandler with the provided options. It requires both a datastore and an authentication service to function properly.
func (*UserHandler) GetCurrentRoles ¶
func (h *UserHandler) GetCurrentRoles(ctx *gin.Context)
GetCurrentRoles returns the roles for the logged-in user
func (*UserHandler) GetCurrentUser ¶
func (h *UserHandler) GetCurrentUser(ctx *gin.Context)
GetCurrentUser returns the currently logged-in user
func (*UserHandler) ListAll ¶
func (h *UserHandler) ListAll(ctx *gin.Context)
ListAll returns a paginated list of all users