Documentation ¶
Index ¶
- Constants
- Variables
- func BadRequest(w http.ResponseWriter, err error)
- func Conflict(w http.ResponseWriter, err error)
- func Forbidden(w http.ResponseWriter, err error)
- func GenerateHagallUserAccessToken(appKey, secret string, ttl time.Duration) (string, error)
- func GetAppKeyFromHTTPRequest(r *http.Request) string
- func GetAppKeyFromHagallUserToken(token string) string
- func GetErrorMessage(err error) string
- func GetUserTokenFromHTTPRequest(r *http.Request) string
- func HTTPError(w http.ResponseWriter, code int, err error)
- func InternalServerError(w http.ResponseWriter, err error)
- func MakeAuthorizationHeader(token string) string
- func MakeJWTSecret() string
- func MethodNotAllowed(w http.ResponseWriter)
- func NormalizeEndpoint(v string) string
- func NotFound(w http.ResponseWriter)
- func NotImplemented(w http.ResponseWriter)
- func NotModified(w http.ResponseWriter)
- func OK(w http.ResponseWriter)
- func OKWithJSON(w http.ResponseWriter, out interface{})
- func PaymentRequired(w http.ResponseWriter, err error)
- func SignIdentity(endpoint, secret string) (string, error)
- func Unauthorized(w http.ResponseWriter, err error)
- func VerifyHagallUserAccessToken(token, secret string) error
- type ClientIDContextValue
- type HagallUserClaim
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 ¶
GenerateHagallUserAccessToken generates a Hagall user access token using the given secret.
func GetAppKeyFromHTTPRequest ¶
GetAppKeyFromHTTPRequest extracts app_key from the HTTP request Authorization header.
func GetAppKeyFromHagallUserToken ¶
Parses the Hagall user token and returns the app key.
func GetErrorMessage ¶
GetErrorMessage returns custom error message from internal error.
func GetUserTokenFromHTTPRequest ¶
Returns the Hagall user token from a HTTP request.
func InternalServerError ¶
func InternalServerError(w http.ResponseWriter, err error)
func MakeAuthorizationHeader ¶
MakeAuthorizationHeader creates a Bearer Authorization header using passed token.
func MethodNotAllowed ¶
func MethodNotAllowed(w http.ResponseWriter)
func NormalizeEndpoint ¶
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 ¶
SignIdentity signs endpoint with secret.
func Unauthorized ¶
func Unauthorized(w http.ResponseWriter, err error)
func VerifyHagallUserAccessToken ¶
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.
Click to show internal directories.
Click to hide internal directories.