2024-10-26 03:56:41 +02:00
|
|
|
package router
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2024-12-11 08:18:43 +01:00
|
|
|
"github.com/ekzyis/magicwallet/db"
|
|
|
|
"github.com/ekzyis/magicwallet/lightning"
|
2024-10-26 03:56:41 +02:00
|
|
|
"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
|
|
|
|
}
|