Add API GetVersion

This commit is contained in:
hantmac
2019-12-19 21:16:25 +08:00
parent 0f3df29d9f
commit 3ab85ef226
3 changed files with 20 additions and 0 deletions

View File

@@ -32,3 +32,4 @@ task:
workers: 4
other:
tmppath: "/tmp"
version: v0.4.1

View File

@@ -176,6 +176,8 @@ func main() {
authGroup.POST("/users/:id", routes.PostUser) // 更改用户
authGroup.DELETE("/users/:id", routes.DeleteUser) // 删除用户
authGroup.GET("/me", routes.GetMe) // 获取自己账户
//release版本
authGroup.GET("/version", routes.GetVersion) //获取发布的版本
}
}

17
backend/routes/version.go Normal file
View File

@@ -0,0 +1,17 @@
package routes
import (
"github.com/gin-gonic/gin"
"github.com/spf13/viper"
"net/http"
)
func GetVersion(c *gin.Context) {
version := viper.GetString("version")
c.JSON(http.StatusOK, Response{
Status: "ok",
Message: "success",
Data: version,
})
}