mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 13:07:09 +00:00
* refactor: update import paths in gateway handlers * refactor: remove obsolete devtools Makefile and README * build: optimize build process for improved efficiency * refactor: remove obsolete pkl files related to Matrix and Sonr network configurations * refactor: move embed code to x/dwn/types
53 lines
1.8 KiB
Go
53 lines
1.8 KiB
Go
package common
|
|
|
|
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 │
|
|
// ╰───────────────────────────────────────────────────────────╯
|
|
|
|
func HeaderEquals(c echo.Context, key HeaderKey, value string) bool {
|
|
return c.Response().Header().Get(key.String()) == value
|
|
}
|
|
|
|
// HeaderExists returns true if the request has the header Key.
|
|
func HeaderExists(c echo.Context, key HeaderKey) bool {
|
|
return c.Response().Header().Get(key.String()) != ""
|
|
}
|
|
|
|
// HeaderRead returns the header value for the Key.
|
|
func HeaderRead(c echo.Context, key HeaderKey) string {
|
|
return c.Response().Header().Get(key.String())
|
|
}
|
|
|
|
// HeaderWrite sets the header value for the Key.
|
|
func HeaderWrite(c echo.Context, key HeaderKey, value string) {
|
|
c.Response().Header().Set(key.String(), value)
|
|
}
|