Documentation
¶
Index ¶
- func GetAuthenticatedUser(ctx context.Context) (*user.User, bool)
- func ParseLimit(limitStr string, defaultLimit, maxLimit int) int
- func ParseOffset(offsetStr string) int
- func RequirePermission(userService user.Service, resourceType, action string) func(http.HandlerFunc) http.HandlerFunc
- func RespondError(w http.ResponseWriter, status int, message string)
- func RespondJSON(w http.ResponseWriter, status int, data interface{})
- func WithAuth(userService user.Service, authService auth.Service) func(http.HandlerFunc) http.HandlerFunc
- type ContextKey
- type ErrorResponse
- type Filter
- type Route
- type TimeRange
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseLimit ¶
ParseLimit parses and validates limit parameter
func ParseOffset ¶
ParseOffset parses and validates offset parameter
func RequirePermission ¶
func RequirePermission(userService user.Service, resourceType, action string) func(http.HandlerFunc) http.HandlerFunc
func RespondError ¶
func RespondError(w http.ResponseWriter, status int, message string)
RespondError sends a standard error response
func RespondJSON ¶
func RespondJSON(w http.ResponseWriter, status int, data interface{})
RespondJSON sends a JSON response with standard headers
func WithAuth ¶
func WithAuth(userService user.Service, authService auth.Service) func(http.HandlerFunc) http.HandlerFunc
WithAuth middleware handles both API key and JWT authentication
Types ¶
type ContextKey ¶
type ContextKey string
Context keys for storing authenticated user info
const (
UserContextKey ContextKey = "user"
)
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
ErrorResponse represents an API error response
type Filter ¶
type Filter struct {
Limit int `json:"limit"`
Offset int `json:"offset"`
Sort []string `json:"sort,omitempty"`
}
Filter represents common query parameters for list operations
type Route ¶
type Route struct {
Path string
Method string
Handler http.HandlerFunc
Middleware []func(http.HandlerFunc) http.HandlerFunc
}
Route represents a route for the HTTP server
type ValidationError ¶
ValidationError represents a field validation error
Click to show internal directories.
Click to hide internal directories.