cors

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...CORSOptions) rex.Middleware

New creates a Cors middleware with default options. If opts argument is provided, it is used instead of defaults. All CORSOptions must be provided since there is no merging with defaults. If the origin is not allowed, a 403 status code is sent.

Types

type CORSOptions

type CORSOptions struct {
	AllowedOrigins   []string // Origins that are allowed in the request, default is all origins
	AllowedMethods   []string // Methods that are allowed in the request
	AllowedHeaders   []string // Headers that are allowed in the request
	ExposedHeaders   []string // Headers that are exposed to the client
	AllowCredentials bool     // Allow credentials like cookies, authorization headers
	MaxAge           int      // Max age in seconds to cache preflight request
	Allowwebsockets  bool     // Allow websockets
}

CORSOptions is the configuration for the CORS middleware.

Jump to

Keyboard shortcuts

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