cors

package
v3.1.34 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config ...Config) core.HandlerFunc

New returns a side-effect-free CORS middleware.

func NewWithApp added in v3.1.28

func NewWithApp(app *core.Core, config ...Config) core.HandlerFunc

NewWithApp constructs CORS middleware and registers a legacy catch-all preflight route. Deprecated: use app.Use(cors.New(config...)).

Types

type Config

type Config struct {
	AllowOrigins     string // 例如: "http://localhost:3000"
	AllowHeaders     string // 默认为空,自动从请求中取
	AllowMethods     string // 默认为 "GET,POST,PUT,DELETE,OPTIONS"
	AllowCredentials bool   // 是否允许带 Cookie / Authorization
	ExposeHeaders    string // 允许浏览器读取的响应头
	MaxAge           string // 预检请求缓存时间(秒)
}

Jump to

Keyboard shortcuts

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