mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
feature/1118 formatter interface creation (#1147)
- **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**
This commit is contained in:
@@ -8,6 +8,11 @@ import (
|
||||
dwngen "github.com/onsonr/sonr/internal/dwn/gen"
|
||||
)
|
||||
|
||||
// ╭───────────────────────────────────────────────────────────╮
|
||||
// │ DWNContext struct methods │
|
||||
// ╰───────────────────────────────────────────────────────────╯
|
||||
|
||||
// DWNContext is the context for DWN endpoints.
|
||||
type DWNContext struct {
|
||||
echo.Context
|
||||
|
||||
@@ -15,15 +20,18 @@ type DWNContext struct {
|
||||
id string // Generated ksuid http cookie; Initialized on first request
|
||||
}
|
||||
|
||||
// HasAuthorization returns true if the request has an Authorization header.
|
||||
func (s *DWNContext) HasAuthorization() bool {
|
||||
v := ReadHeader(s.Context, HeaderAuthorization)
|
||||
return v != ""
|
||||
}
|
||||
|
||||
// ID returns the ksuid http cookie.
|
||||
func (s *DWNContext) ID() string {
|
||||
return s.id
|
||||
}
|
||||
|
||||
// Address returns the sonr address from the cookies.
|
||||
func (s *DWNContext) Address() string {
|
||||
v, err := ReadCookie(s.Context, CookieKeySonrAddr)
|
||||
if err != nil {
|
||||
@@ -32,14 +40,17 @@ func (s *DWNContext) Address() string {
|
||||
return v
|
||||
}
|
||||
|
||||
// IPFSGatewayURL returns the IPFS gateway URL from the headers.
|
||||
func (s *DWNContext) IPFSGatewayURL() string {
|
||||
return ReadHeader(s.Context, HeaderIPFSGatewayURL)
|
||||
}
|
||||
|
||||
// ChainID returns the chain ID from the headers.
|
||||
func (s *DWNContext) ChainID() string {
|
||||
return ReadHeader(s.Context, HeaderSonrChainID)
|
||||
}
|
||||
|
||||
// Schema returns the vault schema from the cookies.
|
||||
func (s *DWNContext) Schema() *dwngen.Schema {
|
||||
v, err := ReadCookie(s.Context, CookieKeyVaultSchema)
|
||||
if err != nil {
|
||||
@@ -53,6 +64,7 @@ func (s *DWNContext) Schema() *dwngen.Schema {
|
||||
return &schema
|
||||
}
|
||||
|
||||
// GetDWNContext returns the DWNContext from the echo context.
|
||||
func GetDWNContext(c echo.Context) (*DWNContext, error) {
|
||||
ctx, ok := c.(*DWNContext)
|
||||
if !ok {
|
||||
|
||||
@@ -6,6 +6,11 @@ import (
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// ╭───────────────────────────────────────────────────────────╮
|
||||
// │ HwayContext struct methods │
|
||||
// ╰───────────────────────────────────────────────────────────╯
|
||||
|
||||
// HwayContext is the context for Highway endpoints.
|
||||
type HwayContext struct {
|
||||
echo.Context
|
||||
|
||||
@@ -13,10 +18,12 @@ type HwayContext struct {
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user