Swagger doc is now included in the application. A fronted can now be hosted from the application.
30 lines
524 B
Go
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")
|
|
}
|