From 6d8bd2c2b5721540f2bcbe11d3b6479ead78c57d Mon Sep 17 00:00:00 2001 From: Lukas SP Date: Sun, 23 Aug 2020 16:40:06 +0200 Subject: [PATCH] Implement information endpoint --- internal/web/web.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/web/web.go b/internal/web/web.go index 0fc0669..2542132 100644 --- a/internal/web/web.go +++ b/internal/web/web.go @@ -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")) } }