ekzyis 75955f5f84 load .env, init db & lnd, render context
* more scaffolding code from delphi.market
* we now read environment from .env
* we now try to init db and lnd but in a non-blocking way
* we now set "render context" to have access to environment during template render
* frontend can now read commit from HTML attribute
2024-10-26 05:59:37 +02:00

31 lines
637 B
Go

package middleware
import (
"net/http"
"github.com/ekzyis/hermes/server/router"
"github.com/labstack/echo/v4"
)
func LndGuard(hc router.Context) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(ec echo.Context) error {
if hc.Lnd != nil {
return next(ec)
}
return echo.NewHTTPError(http.StatusNotImplemented)
}
}
}
func DbGuard(hc router.Context) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(ec echo.Context) error {
if hc.Db != nil {
return next(ec)
}
return echo.NewHTTPError(http.StatusNotImplemented)
}
}
}