mirror of
https://github.com/wonli/aqi.git
synced 2025-12-24 10:40:58 +08:00
template
This commit is contained in:
@@ -121,7 +121,7 @@ func createProject(name, packageName string) {
|
||||
|
||||
// runGoModTidy 在指定目录先更新依赖然后执行
|
||||
func runGoModTidy(projectDir string) error {
|
||||
getCmd := exec.Command("go", "get", "-u", "github.com/wonli/aqi@latest")
|
||||
getCmd := exec.Command("go", "get", "-u", ".")
|
||||
getCmd.Dir = projectDir
|
||||
getCmd.Stdout = os.Stdout
|
||||
getCmd.Stderr = os.Stderr
|
||||
|
||||
@@ -19,7 +19,7 @@ var api = &cobra.Command{
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
app := aqi.Init(
|
||||
aqi.ConfigFile(configFile),
|
||||
aqi.HttpServer("Api", "apiPort"),
|
||||
aqi.HttpServer("Api", "port"),
|
||||
)
|
||||
|
||||
dbc.InitDBC()
|
||||
|
||||
@@ -7,7 +7,7 @@ func GinCORS() gin.HandlerFunc {
|
||||
// 设置响应头中的Access-Control-Allow-Origin为"*",允许所有域名的跨域请求。
|
||||
c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, UPDATE")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Headers", "Origin, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Headers", "Origin, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, Cache-Control, X-Requested-With")
|
||||
c.Writer.Header().Set("Access-Control-Expose-Headers", "Content-Length")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Credentials", "false")
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
func Api(g *gin.Engine) {
|
||||
g.Use(middlewares.GinCORS())
|
||||
g.GET("/ok", func(c *gin.Context) {
|
||||
g.GET("/", func(c *gin.Context) {
|
||||
c.JSON(200, gin.H{
|
||||
"t": time.Now().Unix(),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user