Add index endpoint handler

This commit is contained in:
Andrey Chervyakov 2021-03-13 18:49:20 +06:00
parent a70aac85e7
commit 6d66c5e1f4

View file

@ -6,6 +6,7 @@ import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"link/link"
"net/http"
)
func NewServer(conf *koanf.Koanf, pool *pgxpool.Pool) *echo.Echo {
@ -30,5 +31,13 @@ func addMiddleware(s *echo.Echo, conf *koanf.Koanf) {
}
func addHandlers(s *echo.Echo, pool *pgxpool.Pool) {
s.GET("", func(ctx echo.Context) error {
return ctx.JSON(http.StatusOK, struct {
Message string `json:"message"`
}{
Message: "Hello. This is my (https://cognio.dev/) URL shortener for easy access to my socials, projects and other resources.",
})
})
link.AddHandlers(s, pool)
}