Files
MusicServer/pkg/api/index.go
Sebastian f9d6c24a97 Changed routing framework from mux to Gin.
Swagger doc is now included in the application.
A fronted can now be hosted from the application.
2022-01-29 17:52:33 +01:00

30 lines
524 B
Go

package api
import (
"github.com/gin-gonic/gin"
"music-server/pkg/helpers"
"music-server/pkg/server"
"net/http"
)
type Index struct {
}
func NewIndex() *Index {
return &Index{}
}
func (i *Index) GetVersion(ctx *gin.Context) {
versionHistory := server.GetVersionHistory()
if versionHistory.Version == "" {
helpers.NewError(ctx, http.StatusNotFound, nil)
return
}
ctx.JSON(http.StatusOK, versionHistory)
}
func (i *Index) GetDBTest(ctx *gin.Context) {
server.TestDB()
ctx.JSON(http.StatusOK, "TestedDB")
}