magicwallet/server/router/middleware/lnd.go

31 lines
642 B
Go
Raw Normal View History

package middleware
import (
"net/http"
2024-12-11 07:18:43 +00:00
"github.com/ekzyis/magicwallet/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)
}
}
}