Commit 9d7afea4 by huangchengyi

1.0

parent 2e834757
The file could not be displayed because it is too large.
......@@ -8,11 +8,12 @@ import (
)
func Cors() gin.HandlerFunc {
corsDomain := config.Get("web.cors_domain").Strings(",")
corsDomain = append(corsDomain, "https://bom.ichunt.com")
corsDomain = append(corsDomain, "https://bom.ichunt.com")
return cors.New(cors.Config{
AllowOrigins: corsDomain,
AllowHeaders: []string{"x-requested-with", "Authorization", "Content-Type"},
AllowMethods: []string{"POST", "GET", "PUT", "DELETE"},
AllowCredentials: true,
MaxAge: 12 * time.Hour,
......
......@@ -5,7 +5,6 @@ import (
"github.com/gin-gonic/gin"
"runtime"
"strconv"
"strings"
)
type Response struct {
......@@ -54,10 +53,10 @@ func Output(ctx *gin.Context,errCode int, errMsg string, data interface{}) {
if ctx.DefaultQuery("callback", "") != "" {
ctx.JSONP(200, response)
} else {
referer := ctx.Request.Referer()
referer = strings.TrimRight(referer, "/")
ctx.Header("Access-Control-Allow-Origin", referer)
ctx.Header("Access-Control-Allow-Credentials", "true")
//referer := ctx.Request.Referer()
//referer = strings.TrimRight(referer, "/")
//ctx.Header("Access-Control-Allow-Origin", referer)
//ctx.Header("Access-Control-Allow-Credentials", "true")
//允许跨站访问的站点域名
//跨域请求头设置
ctx.JSON(200, response)
......
package mongo
import (
"fmt"
"gopkg.in/mgo.v2"
"search_server/pkg/config"
"strconv"
......@@ -30,8 +29,8 @@ func getconn(mongoConfig config.MongoDbDatabase) (*mgo.Session ,error){
if err != nil {
return nil ,err
}
fmt.Println("url",url)
fmt.Println("maxPoolSizeInt",maxPoolSizeInt)
//fmt.Println("url",url)
//fmt.Println("maxPoolSizeInt",maxPoolSizeInt)
session.SetPoolLimit(maxPoolSizeInt)
session.SetMode(mgo.Monotonic, true)
myDB :=session.DB(mongoConfig.Database)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment