Documentation
¶
Overview ¶
Package cors provides CORS middleware for HTTP handlers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
AllowOrigins []string
AllowMethods []string
AllowHeaders []string
ExposeHeaders []string
AllowCredentials bool
MaxAge int // preflight cache duration in seconds
}
Config holds CORS configuration.
type Option ¶
type Option func(*Config)
Option configures CORS behavior.
func WithCredentials ¶
WithCredentials enables credentials (cookies, auth headers).
func WithHeaders ¶
WithHeaders sets the allowed request headers.
func WithMaxAge ¶
WithMaxAge sets the preflight cache duration in seconds.
func WithMethods ¶
WithMethods sets the allowed HTTP methods.
func WithOrigins ¶
WithOrigins sets the allowed origins. Use "*" to allow all.
Click to show internal directories.
Click to hide internal directories.