http

package
v0.1.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2024 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

View Source
const (
	HeaderHagallIDKey                         = "Hagall-Id"
	HeaderHagallJWTSecretHeaderKey            = "Hagall-Jwt-Secret"
	HeaderHagallJWTChallengeHeaderKey         = "Hagall-Jwt-Challenge"
	HeaderHagallJWTChallengeSolutionHeaderKey = "Hagall-Jwt-Challenge-Solution"
	HeaderHagallRegistrationStateKey          = "Hagall-Registration-State"
	HeaderPosemeshClientID                    = "posemesh-client-id"

	CloudFrontTimezoneNameHeaderKey  = "CloudFront-Viewer-Time-Zone"
	CloudFrontCountryNameHeaderKey   = "CloudFront-Viewer-Country"
	CloudFrontViewerAddressHeaderKey = "CloudFront-Viewer-Address"

	XForwardedForHeaderKey = "X-Forwarded-For"
)

Variables

View Source
var (
	ErrDuplicatedWalletAddress = errors.New("duplicated wallet address")
	ErrBadRequest              = errors.New("invalid request body")
)

Functions

func BadRequest

func BadRequest(w http.ResponseWriter, err error)

func Conflict

func Conflict(w http.ResponseWriter, err error)

func Forbidden

func Forbidden(w http.ResponseWriter, err error)

func GenerateHagallUserAccessToken

func GenerateHagallUserAccessToken(appKey, secret string, ttl time.Duration) (string, error)

GenerateHagallUserAccessToken generates a Hagall user access token using the given secret.

func GetAppKeyFromHTTPRequest

func GetAppKeyFromHTTPRequest(r *http.Request) string

GetAppKeyFromHTTPRequest extracts app_key from the HTTP request Authorization header.

func GetAppKeyFromHagallUserToken

func GetAppKeyFromHagallUserToken(token string) string

Parses the Hagall user token and returns the app key.

func GetErrorMessage

func GetErrorMessage(err error) string

GetErrorMessage returns custom error message from internal error.

func GetUserTokenFromHTTPRequest

func GetUserTokenFromHTTPRequest(r *http.Request) string

Returns the Hagall user token from a HTTP request.

func HTTPError

func HTTPError(w http.ResponseWriter, code int, err error)

func InternalServerError

func InternalServerError(w http.ResponseWriter, err error)

func MakeAuthorizationHeader

func MakeAuthorizationHeader(token string) string

MakeAuthorizationHeader creates a Bearer Authorization header using passed token.

func MakeJWTSecret

func MakeJWTSecret() string

MakeJWTSecret creates a random secret string.

func MethodNotAllowed

func MethodNotAllowed(w http.ResponseWriter)

func NormalizeEndpoint

func NormalizeEndpoint(v string) string

func NotFound

func NotFound(w http.ResponseWriter)

func NotImplemented

func NotImplemented(w http.ResponseWriter)

func NotModified

func NotModified(w http.ResponseWriter)

func OK

func OK(w http.ResponseWriter)

func OKWithJSON

func OKWithJSON(w http.ResponseWriter, out interface{})

func PaymentRequired

func PaymentRequired(w http.ResponseWriter, err error)

func SignIdentity

func SignIdentity(endpoint, secret string) (string, error)

SignIdentity signs endpoint with secret.

func Unauthorized

func Unauthorized(w http.ResponseWriter, err error)

func VerifyHagallUserAccessToken

func VerifyHagallUserAccessToken(token, secret string) error

VerifyHagallUserAccessToken verifies signed token with the secret.

Types

type ClientIDContextValue

type ClientIDContextValue string

type HagallUserClaim

type HagallUserClaim struct {
	jwt.RegisteredClaims

	AppKey string `json:"app_key"`
}

HagallUserClaim is the claims to generate a Hagall User JWT token.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL