diff --git a/backend/conf/config.yml b/backend/conf/config.yml index 60d2bd41..d5503878 100644 --- a/backend/conf/config.yml +++ b/backend/conf/config.yml @@ -32,3 +32,4 @@ task: workers: 4 other: tmppath: "/tmp" +version: v0.4.1 \ No newline at end of file diff --git a/backend/main.go b/backend/main.go index 0d7b7cc1..ace026cc 100644 --- a/backend/main.go +++ b/backend/main.go @@ -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) //获取发布的版本 } } diff --git a/backend/routes/version.go b/backend/routes/version.go new file mode 100644 index 00000000..719732ad --- /dev/null +++ b/backend/routes/version.go @@ -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, + }) +}