27 lines
642 B
Go
27 lines
642 B
Go
package router
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/ekzyis/magicwallet/db"
|
|
"github.com/ekzyis/magicwallet/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
|
|
}
|