diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 0de3cc4..ca6b12f 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,11 +3,6 @@ - - - - - @@ -36,7 +31,7 @@ - + @@ -50,8 +45,9 @@ - - + + + diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..004e2c6 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,18 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceRoot}/main.go", + "env": {}, + "args": [], + "cwd":".", + } + ] + } \ No newline at end of file diff --git a/main.go b/main.go index 9b99898..087681d 100644 --- a/main.go +++ b/main.go @@ -7,35 +7,35 @@ import ( "background/db" "background/logs" "background/model" - "github.com/gin-gonic/gin" - "github.com/tommy351/gin-sessions" "log" "strconv" + + "github.com/gin-gonic/gin" + sessions "github.com/tommy351/gin-sessions" ) var ( - userController = controller.UserController{} - mailContoller = controller.MailController{} - fileController = controller.FileController{} + userController = controller.UserController{} + mailContoller = controller.MailController{} + fileController = controller.FileController{} webhookController = controller.WebHookController{} ) - func CORSMiddleware(c *gin.Context) { c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, UPDATE") - if config.ApiConfig().RunMode == "release"{ + if config.ApiConfig().RunMode == "release" { c.Writer.Header().Set("Access-Control-Allow-Origin", "https://testingcloud.club") - }else{ + } else { c.Writer.Header().Set("Access-Control-Allow-Origin", "http://localhost:8080") } c.Writer.Header().Set("Access-Control-Max-Age", "86400") c.Writer.Header().Set("Access-Control-Allow-Headers", - "X-Requested-With," + - " Content-Type, Origin, Authorization," + - "Accept,Client-Security-Token, Accept-Encoding," + - "x-access-token,Access-Control-Request-Method," + - "Access-Control-Request-Headers") + "X-Requested-With,"+ + " Content-Type, Origin, Authorization,"+ + "Accept,Client-Security-Token, Accept-Encoding,"+ + "x-access-token,Access-Control-Request-Method,"+ + "Access-Control-Request-Headers") c.Writer.Header().Set("Access-Control-Expose-Headers", "Content-Length") c.Writer.Header().Set("Access-Control-Allow-Credentials", "true") @@ -71,9 +71,9 @@ func InitRedisConfig() { } } -func InitElasticSearch(){ - e := db.GetElastic().CreateIndex("hardware",model.HardwareTypeMapping()) - if nil != e{ +func InitElasticSearch() { + e := db.GetElastic().CreateIndex("hardware", model.HardwareTypeMapping()) + if nil != e { } } @@ -143,7 +143,7 @@ func main() { } hookapi := r.Group("hookapi") { - hookapi.POST("/push_hook/:repo",webhookController.PushHook) + hookapi.POST("/push_hook/:repo", webhookController.PushHook) } e := r.Run(":" + strconv.Itoa(config.GetPort())) if nil != e {