* 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
27 lines
632 B
Go
27 lines
632 B
Go
package router
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/ekzyis/hermes/db"
|
|
"github.com/ekzyis/hermes/lightning"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
type Context struct {
|
|
context.Context
|
|
Environment string
|
|
CommitShortSha string
|
|
Db *db.DB
|
|
Lnd *lightning.LNDClient
|
|
}
|
|
|
|
func (hc *Context) WithContext(ec echo.Context) context.Context {
|
|
ctx := ec.Request().Context()
|
|
ctx = context.WithValue(ctx, "env", hc.Environment)
|
|
ctx = context.WithValue(ctx, "session", ec.Get("session"))
|
|
ctx = context.WithValue(ctx, "commit", hc.CommitShortSha)
|
|
ctx = context.WithValue(ctx, "path", ec.Request().URL.Path)
|
|
return ctx
|
|
}
|