Implement information endpoint

This commit is contained in:
Lukas SP 2020-08-23 16:40:06 +02:00
parent 7b8fab05a2
commit 6d8bd2c2b5
1 changed files with 7 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"encoding/json"
"github.com/Lukaesebrot/pasty/internal/env"
"github.com/Lukaesebrot/pasty/internal/pastes"
"github.com/Lukaesebrot/pasty/internal/static"
"github.com/Lukaesebrot/pasty/internal/storage"
v1 "github.com/Lukaesebrot/pasty/internal/web/controllers/v1"
routing "github.com/fasthttp/router"
@ -39,6 +40,12 @@ func Serve() error {
{
v1Route := apiRoute.Group("/v1")
{
v1Route.GET("/info", func(ctx *fasthttp.RequestCtx) {
jsonData, _ := json.Marshal(map[string]string{
"version": static.Version,
})
ctx.SetBody(jsonData)
})
v1.InitializePastesController(v1Route.Group("/pastes"))
}
}