This commit is contained in:
ideaa
2025-09-29 10:46:11 +08:00
parent bdb4799a83
commit 84e2589b68
4 changed files with 4 additions and 4 deletions

View File

@@ -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

View File

@@ -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()

View File

@@ -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")

View File

@@ -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(),
})