Documentation ¶
Index ¶
- Constants
- func Chain(h http.Handler, middlewares ...Middleware) http.Handler
- func ContextGet(r *http.Request) *models.User
- func ContextSetRequestId(r *http.Request, requestId string) *http.Request
- func ContextSetUser(r *http.Request, user *models.User) *http.Request
- func GetRequestID(ctx context.Context) string
- type CustomClaims
- type Middleware
- type MiddlewareConfig
- type MiddlewareHandler
- type ResponseWriter
- type TokenError
Constants ¶
View Source
const LoggerContextKey contextKey = "logger"
View Source
const RequestIDContextKey contextKey = "request_id"
Variables ¶
This section is empty.
Functions ¶
func ContextSetRequestId ¶
func GetRequestID ¶
Types ¶
type CustomClaims ¶
type CustomClaims struct { jwt.RegisteredClaims UserID string `json:"userId,omitempty"` }
func ValidateToken ¶
ValidateToken parses and validates the JWT token
type Middleware ¶
func Recovery ¶
func Recovery(logger *slog.Logger) Middleware
func RequireActiveUser ¶
func RequireActiveUser(logger *slog.Logger, db *database.Queries) Middleware
type MiddlewareConfig ¶
type MiddlewareHandler ¶
type MiddlewareHandler struct {
// contains filtered or unexported fields
}
func NewMiddlewareHandler ¶
func NewMiddlewareHandler(logger *slog.Logger, config MiddlewareConfig) *MiddlewareHandler
func (*MiddlewareHandler) Auth ¶
func (m *MiddlewareHandler) Auth(userRepository repository.UserRepository) Middleware
func (*MiddlewareHandler) Logger ¶
func (m *MiddlewareHandler) Logger() Middleware
type ResponseWriter ¶
type ResponseWriter struct { http.ResponseWriter // contains filtered or unexported fields }
Custom ResponseWriter to capture status code
func NewResponseWriter ¶
func NewResponseWriter(w http.ResponseWriter) *ResponseWriter
func (*ResponseWriter) Status ¶
func (rw *ResponseWriter) Status() int
func (*ResponseWriter) WriteHeader ¶
func (rw *ResponseWriter) WriteHeader(code int)
type TokenError ¶
type TokenError struct {
// contains filtered or unexported fields
}
func (*TokenError) Error ¶
func (e *TokenError) Error() string
Click to show internal directories.
Click to hide internal directories.