liuxiaolong
2020-07-30 c8078a36e3e15139ac3d9fb2df7d9154c6ea8ee2
test
1个文件已修改
20 ■■■■■ 已修改文件
routers/router.go 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
routers/router.go
@@ -9,7 +9,11 @@
import (
    "car-service/controllers"
    "fmt"
    "github.com/astaxie/beego/plugins/cors"
    "os"
    "os/exec"
    "path/filepath"
    "github.com/astaxie/beego"
)
@@ -39,7 +43,9 @@
    //)
    //beego.AddNamespace(ns)
    //beego.Router("/basic/api/car/app/user", &controllers.UserController{})
    beego.SetStaticPath("/download", "download")
    rootPath := getAppRootPath()
    fmt.Println("rootPath:", rootPath)
    beego.SetStaticPath("/download", "/data3/workspace/liuxiaolong/car-service/download")
    preApi := "/basic/api"
    beego.Router(preApi+"/car/statistic", &controllers.CarController{}, "*:Statistic")
    beego.Router(preApi+"/car/spaceNo", &controllers.CarController{}, "*:SpaceNo")
@@ -54,3 +60,15 @@
    beego.Router(preApi+"/user/all", &controllers.UserController{}, "*:GetUserAll")
}
func getAppRootPath() string {
    file,err:= exec.LookPath(os.Args[0])
    if err != nil {
        return ""
    }
    p, err := filepath.Abs(file)
    if err != nil {
        return ""
    }
    return filepath.Dir(p)
}