cors

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCORS added in v0.0.3

func NewCORS(options ...Option) httpx.Middleware

NewCORS creates an httpx middleware that applies configurable CORS headers. By default it allows all origins, standard HTTP verbs, and reflects requested headers.

Types

type Option added in v0.0.3

type Option func(*config)

Option configures the behavior of the CORS middleware.

func WithAllowCredentials added in v0.0.3

func WithAllowCredentials(enabled bool) Option

WithAllowCredentials enables or disables the Access-Control-Allow-Credentials header.

func WithAllowHeaders added in v0.0.3

func WithAllowHeaders(headers ...string) Option

WithAllowHeaders sets the allowed request headers for preflight requests.

func WithAllowMethods added in v0.0.3

func WithAllowMethods(methods ...string) Option

WithAllowMethods sets the HTTP methods that are allowed for CORS requests.

func WithAllowOrigins added in v0.0.3

func WithAllowOrigins(origins ...string) Option

WithAllowOrigins sets the list of allowed origins. Use "*" to allow any origin.

func WithExposeHeaders added in v0.0.3

func WithExposeHeaders(headers ...string) Option

WithExposeHeaders defines which headers are exposed to browser clients.

func WithMaxAge added in v0.0.3

func WithMaxAge(ttl time.Duration) Option

WithMaxAge sets how long the results of a preflight request can be cached.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL