Commit 9d7afea4 by huangchengyi

1.0

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