增加跨域处理的中间件
This commit is contained in:
40
middleware/request_cors/config.go
Normal file
40
middleware/request_cors/config.go
Normal file
@ -0,0 +1,40 @@
|
||||
// Package request_cors ...
|
||||
//
|
||||
// Description : request_cors ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2022-07-13 16:27
|
||||
package request_cors
|
||||
|
||||
import "net/http"
|
||||
|
||||
type cors struct {
|
||||
allowAllOrigins bool
|
||||
allowCredentials bool
|
||||
allowOriginFunc func(string) bool
|
||||
allowOrigins []string
|
||||
normalHeaders http.Header
|
||||
preflightHeaders http.Header
|
||||
wildcardOrigins [][]string
|
||||
}
|
||||
|
||||
var (
|
||||
DefaultSchemas = []string{
|
||||
"http://",
|
||||
"https://",
|
||||
}
|
||||
ExtensionSchemas = []string{
|
||||
"chrome-extension://",
|
||||
"safari-extension://",
|
||||
"moz-extension://",
|
||||
"ms-browser-extension://",
|
||||
}
|
||||
FileSchemas = []string{
|
||||
"file://",
|
||||
}
|
||||
WebSocketSchemas = []string{
|
||||
"ws://",
|
||||
"wss://",
|
||||
}
|
||||
)
|
Reference in New Issue
Block a user