Documentation
¶
Overview ¶
Package cors provides handlers to enable CORS support. Usage
import ( "github.com/beego/beego/v2" "github.com/beego/beego/v2/server/web/filter/cors"
)
func main() {
// CORS for https://foo.* origins, allowing:
// - PUT and PATCH methods
// - Origin header
// - Credentials share
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowOrigins: []string{"https://*.foo.com"},
AllowMethods: []string{"PUT", "PATCH"},
AllowHeaders: []string{"Origin"},
ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true,
}))
beego.Run()
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Allow ¶
func Allow(opts *Options) beego.FilterFunc
Allow enables CORS for requests those match the provided options.
Types ¶
Click to show internal directories.
Click to hide internal directories.