...
|
...
|
@@ -5,10 +5,12 @@ import ( |
|
|
"errors"
|
|
|
"fmt"
|
|
|
"github.com/astaxie/beego/context"
|
|
|
"github.com/astaxie/beego/plugins/cors"
|
|
|
"github.com/tiptok/gocomm/common"
|
|
|
"github.com/tiptok/gocomm/pkg/log"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/cachex"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
|
|
|
"net/http"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
...
|
...
|
@@ -120,3 +122,22 @@ func CreateResponseLogFilter() func(ctx *context.Context) { |
|
|
log.Debug(fmt.Sprintf("<====Send User:%v RequestId:%v BodyData:%s", ctx.Input.GetData("x-mmm-id"), requestId, body))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func AllowCors() func(ctx *context.Context) {
|
|
|
return func(ctx *context.Context) {
|
|
|
if ctx.Request.Method != "OPTIONS" {
|
|
|
return
|
|
|
}
|
|
|
f := cors.Allow(&cors.Options{
|
|
|
AllowOrigins: []string{"*"},
|
|
|
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
|
|
AllowHeaders: []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Content-Type", "x-requested-with"},
|
|
|
ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin"},
|
|
|
AllowCredentials: true,
|
|
|
})
|
|
|
f(ctx)
|
|
|
ctx.Output.Body([]byte("{}"))
|
|
|
ctx.Output.SetStatus(http.StatusNoContent)
|
|
|
return
|
|
|
}
|
|
|
} |
...
|
...
|
|