go: add a handler for admin endpoint(s)

This commit is contained in:
leo 2023-03-22 23:11:14 +01:00
parent 5cfad662fc
commit 5937a24ad9
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ
2 changed files with 17 additions and 0 deletions

@ -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())
}

13
handlers/handlers.go Normal file

@ -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")
}
}