...
|
...
|
@@ -7,6 +7,7 @@ import ( |
|
|
"fmt"
|
|
|
"github.com/astaxie/beego/plugins/cors"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/time"
|
|
|
"net/http"
|
|
|
protocol "openapi/pkg/domain"
|
|
|
"strconv"
|
|
|
"strings"
|
...
|
...
|
@@ -179,3 +180,18 @@ func (this *BaseController) Finish() { |
|
|
log.Debug(fmt.Sprintf("<====Send to uid(%d) ucid(%v) client: %d byte\nRequestId:%s RspBodyData: %s", this.Header.Uid, this.Header.UserId, length, this.Header.GetRequestId(), string(strByte)))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func AllowCors() func(ctx *context.Context) {
|
|
|
return func(ctx *context.Context) {
|
|
|
ctx.Output.Header("Access-Control-Allow-Methods", "OPTIONS,DELETE,POST,GET,PUT,PATCH")
|
|
|
//ctx.Output.Header("Access-Control-Max-Age", "3600")
|
|
|
ctx.Output.Header("Access-Control-Allow-Headers", "*")
|
|
|
ctx.Output.Header("Access-Control-Allow-Credentials", "true")
|
|
|
ctx.Output.Header("Access-Control-Allow-Origin", "*") //origin
|
|
|
if ctx.Input.Method() == http.MethodOptions {
|
|
|
// options请求,返回200
|
|
|
ctx.Output.SetStatus(http.StatusOK)
|
|
|
_ = ctx.Output.Body([]byte("options support"))
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|