Files
motr/middleware/headers/headers.go
Prad Nukala 786fef8399 Implement Database Migrations (#12)
* feat: enhance modularity by relocating core packages

* refactor: move chart components to dashboard package

* refactor: restructure database access layer

* refactor: rename credential descriptor to credentials for clarity

* feat: enhance development environment configuration for database interactions

* feat: integrate go-task for database migrations

* feat: introduce middleware for market data and WebAuthn
2025-05-29 15:07:20 -04:00

57 lines
1.9 KiB
Go

//go:build js && wasm
// +build js,wasm
package headers
import "github.com/labstack/echo/v4"
type HeaderKey string
const (
Authorization HeaderKey = "Authorization"
// User Agent
Architecture HeaderKey = "Sec-CH-UA-Arch"
Bitness HeaderKey = "Sec-CH-UA-Bitness"
FullVersionList HeaderKey = "Sec-CH-UA-Full-Version-List"
Mobile HeaderKey = "Sec-CH-UA-Mobile"
Model HeaderKey = "Sec-CH-UA-Model"
Platform HeaderKey = "Sec-CH-UA-Platform"
PlatformVersion HeaderKey = "Sec-CH-UA-Platform-Version"
UserAgent HeaderKey = "Sec-CH-UA"
// Sonr Injected
SonrAPIURL HeaderKey = "X-Sonr-API"
SonrgRPCURL HeaderKey = "X-Sonr-GRPC"
SonrRPCURL HeaderKey = "X-Sonr-RPC"
SonrWSURL HeaderKey = "X-Sonr-WS"
)
func (h HeaderKey) String() string {
return string(h)
}
// ╭───────────────────────────────────────────────────────────╮
// │ Utility Methods │
// ╰───────────────────────────────────────────────────────────╯
// MustEqual returns true if the request has the header Key.
func (k HeaderKey) MustEqual(c echo.Context, value string) bool {
return c.Response().Header().Get(k.String()) == value
}
// Exists returns true if the request has the header Key.
func (k HeaderKey) Exists(c echo.Context) bool {
return c.Response().Header().Get(k.String()) != ""
}
// Read returns the header value for the Key.
func (k HeaderKey) Read(c echo.Context) string {
return c.Response().Header().Get(k.String())
}
// Write sets the header value for the Key.
func (k HeaderKey) Write(c echo.Context, value string) {
c.Response().Header().Set(k.String(), value)
}