Move version definition into command package, include build timestamp, add /api/info endpoint
This commit is contained in:
@@ -197,3 +197,13 @@ func GetBookmarks(c *gin.Context) {
|
||||
bookmarks, err := bookmarks.ReadAll(bookmarks.Path())
|
||||
serveResult(bookmarks, err, c)
|
||||
}
|
||||
|
||||
func GetInfo(c *gin.Context) {
|
||||
info := map[string]string{
|
||||
"version": command.VERSION,
|
||||
"git_sha": command.GitCommit,
|
||||
"build_time": command.BuildTime,
|
||||
}
|
||||
|
||||
c.JSON(200, info)
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ func NewError(err error) Error {
|
||||
// Middleware function to check database connection status before running queries
|
||||
func dbCheckMiddleware() gin.HandlerFunc {
|
||||
allowedPaths := []string{
|
||||
"/api/info",
|
||||
"/api/connect",
|
||||
"/api/bookmarks",
|
||||
"/api/history",
|
||||
|
||||
@@ -12,6 +12,7 @@ func SetupRoutes(router *gin.Engine) {
|
||||
{
|
||||
api.Use(dbCheckMiddleware())
|
||||
|
||||
api.GET("/info", GetInfo)
|
||||
api.POST("/connect", Connect)
|
||||
api.GET("/databases", GetDatabases)
|
||||
api.GET("/connection", GetConnectionInfo)
|
||||
|
||||
8
pkg/command/version.go
Normal file
8
pkg/command/version.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package command
|
||||
|
||||
const VERSION = "0.5.2"
|
||||
|
||||
var (
|
||||
GitCommit string
|
||||
BuildTime string
|
||||
)
|
||||
Reference in New Issue
Block a user