mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 13:07:09 +00:00
- **refactor: improve query service code structure** - **chore(deps): update protoc-gen-go-grpc to v1.5.1** - **refactor: replace package with** - **chore(deps): update dependencies** - **fix(deps): update webauthn to v0.11.2** - **refactor: remove onsonr.sonr from package names** - **refactor: improve code readability in vault querier** - **refactor: simplify controller initialization** - **fix: remove unnecessary function for counter data** - **refactor: update button component file paths** - **refactor(authentication): simplify register page** - **fix: update error filenames in marketing section templates**
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package ctx
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
// ╭───────────────────────────────────────────────────────────╮
|
|
// │ HwayContext struct methods │
|
|
// ╰───────────────────────────────────────────────────────────╯
|
|
|
|
// HwayContext is the context for Highway endpoints.
|
|
type HwayContext struct {
|
|
echo.Context
|
|
|
|
// Defaults
|
|
id string // Generated ksuid http cookie; Initialized on first request
|
|
}
|
|
|
|
// ID returns the ksuid http cookie
|
|
func (s *HwayContext) ID() string {
|
|
return s.id
|
|
}
|
|
|
|
// GetHwayContext returns the HwayContext from the echo context.
|
|
func GetHWAYContext(c echo.Context) (*HwayContext, error) {
|
|
ctx, ok := c.(*HwayContext)
|
|
if !ok {
|
|
return nil, echo.NewHTTPError(http.StatusInternalServerError, "Highway Context not found")
|
|
}
|
|
return ctx, nil
|
|
}
|
|
|
|
// HighwaySessionMiddleware establishes a Session Cookie.
|
|
func HighwaySessionMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
|
|
return func(c echo.Context) error {
|
|
sessionID := GetSessionID(c)
|
|
cc := &HwayContext{
|
|
Context: c,
|
|
id: sessionID,
|
|
}
|
|
return next(cc)
|
|
}
|
|
}
|