* if a request has no session cookie, a new user, session and wallet is created and session cookie is set * if a request has a session cookie and session exists in db, we will fetch user and wallet from db * this means that we have a user and wallet during each render without any login required
20 lines
392 B
Go
20 lines
392 B
Go
package middleware
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/ekzyis/magicwallet/server/router/context"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
func LndGuard(hc context.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)
|
|
}
|
|
}
|
|
}
|