Documentation
¶
Index ¶
- func AdminMiddleware(userStore UserStoreForAdmin) func(http.Handler) http.Handler
- func AuthMiddleware(next http.Handler) http.Handler
- func CORSMiddleware(next http.Handler) http.Handler
- func DeleteCarImages(ctx context.Context, imageURLs []string)
- func GetCarImages(ctx context.Context, carID string) []string
- func GetEmailFromContext(ctx context.Context) (string, bool)
- func GetUserRoleFromContext(ctx context.Context) (string, bool)
- func ImageUploadMiddleware(next http.Handler) http.Handler
- func MetricMiddleware(next http.Handler) http.Handler
- func ValidateToken(tokenString string) (string, error)
- type UserStoreForAdmin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdminMiddleware ¶
func AdminMiddleware(userStore UserStoreForAdmin) func(http.Handler) http.Handler
AdminMiddleware is a middleware that checks if the authenticated user has admin role It must be used after AuthMiddleware as it depends on the email being set in context
func CORSMiddleware ¶
CORSMiddleware adds CORS headers to allow cross-origin requests
func DeleteCarImages ¶
DeleteCarImages removes all images for a deleted car
func GetCarImages ¶
GetCarImages is a placeholder function for getting existing car images This should be implemented when you update the car store
func GetEmailFromContext ¶
GetEmailFromContext extracts the email from the request context
func GetUserRoleFromContext ¶
GetUserRoleFromContext extracts the user role from the request context
func ImageUploadMiddleware ¶
ImageUploadMiddleware handles image uploads to Cloudinary
func ValidateToken ¶
ValidateToken validates a JWT token and returns the email (stored in Subject) if valid