1
0
mirror of https://github.com/lus/pasty.git synced 2023-08-10 21:13:09 +03:00

Implement information endpoint

This commit is contained in:
Lukas SP 2020-08-23 16:40:06 +02:00
parent 7b8fab05a2
commit 6d8bd2c2b5

View File

@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"github.com/Lukaesebrot/pasty/internal/env" "github.com/Lukaesebrot/pasty/internal/env"
"github.com/Lukaesebrot/pasty/internal/pastes" "github.com/Lukaesebrot/pasty/internal/pastes"
"github.com/Lukaesebrot/pasty/internal/static"
"github.com/Lukaesebrot/pasty/internal/storage" "github.com/Lukaesebrot/pasty/internal/storage"
v1 "github.com/Lukaesebrot/pasty/internal/web/controllers/v1" v1 "github.com/Lukaesebrot/pasty/internal/web/controllers/v1"
routing "github.com/fasthttp/router" routing "github.com/fasthttp/router"
@ -39,6 +40,12 @@ func Serve() error {
{ {
v1Route := apiRoute.Group("/v1") 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")) v1.InitializePastesController(v1Route.Group("/pastes"))
} }
} }