Documentation
¶
Index ¶
- Constants
- func AuthMiddleware(next http.Handler) http.Handler
- func GetUserID(w http.ResponseWriter, r *http.Request, logger *slog.Logger) (uuid.UUID, bool)
- func MapGrpcToHttpStatus(err error) (statusCode int, message string)
- func ParseID(w http.ResponseWriter, r *http.Request, logger *slog.Logger) (uuid.UUID, bool)
- func ParseValidateGt(r *http.Request, w http.ResponseWriter, logger *slog.Logger, key string, ...) (int32, bool)
- func ParseValidateGte(r *http.Request, w http.ResponseWriter, logger *slog.Logger, key string, ...) (int32, bool)
- func Recoverer(logger *slog.Logger) func(next http.Handler) http.Handler
- func RespondError(w http.ResponseWriter, logger *slog.Logger, status int, message string)
- func RespondJSON(w http.ResponseWriter, logger *slog.Logger, status int, payload any)
- func StructuredLogger(logger *slog.Logger) func(next http.Handler) http.Handler
- func TelemetryEnricher(next http.Handler) http.Handler
- type ParamValidator
Constants ¶
View Source
const UserIDKey = contextKey("userID")
View Source
const XUserId = "X-User-Id"
Variables ¶
This section is empty.
Functions ¶
func GetUserID ¶
GetUserID retrieves the user ID from the request context. Returns the user ID and a boolean indicating success.
func MapGrpcToHttpStatus ¶
func ParseID ¶
ParseID extracts and validates the ID from the request path. Returns the ID and a boolean indicating success.
func ParseValidateGt ¶
func ParseValidateGte ¶
func Recoverer ¶
Recoverer is a middleware that recovers from panics and logs them using the provided logger.
func RespondError ¶
func RespondJSON ¶
func StructuredLogger ¶
StructuredLogger creates a middleware that logs HTTP requests in a structured format.
Types ¶
type ParamValidator ¶
ParamValidator is a function type that validates a parameter.
Click to show internal directories.
Click to hide internal directories.