From 5937a24ad9841d959ed8c819f99710fd29294053 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 22 Mar 2023 23:11:14 +0100 Subject: [PATCH] go: add a handler for admin endpoint(s) --- app/routes.go | 4 ++++ handlers/handlers.go | 13 +++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 handlers/handlers.go diff --git a/app/routes.go b/app/routes.go index ccb3190..eae2273 100644 --- a/app/routes.go +++ b/app/routes.go @@ -3,6 +3,7 @@ package app import ( "net/http" + "git.dotya.ml/mirre-mt/pcmt/handlers" "github.com/labstack/echo/v4" ) @@ -15,4 +16,7 @@ func (a *App) SetupRoutes() { e.HEAD("/", func(c echo.Context) error { return c.NoContent(http.StatusOK) }) + + // administrative endpoints. + e.GET("/admin", handlers.Admin()) } diff --git a/handlers/handlers.go b/handlers/handlers.go new file mode 100644 index 0000000..dc92400 --- /dev/null +++ b/handlers/handlers.go @@ -0,0 +1,13 @@ +package handlers + +import ( + "net/http" + + "github.com/labstack/echo/v4" +) + +func Admin() echo.HandlerFunc { + return func(c echo.Context) error { + return echo.NewHTTPError(http.StatusUnauthorized, "Invalid credentials") + } +}