Documentation ¶
Index ¶
- Variables
- type APIResponse
- type Authorization
- type CallType
- type Claims
- type ClientType
- type CustomHeader
- type Error
- type ErrorSource
- type ErrorType
- type GQL2Config
- type GQLClient
- type GQLClient2
- type GQLConfig
- type HTTPClient
- type HTTPConfig
- type HasuraActionRequestPayload
- type HasuraActionResponse
- type HasuraActionsResponseExtensions
- type HasuraClaims
- type HasuraClient
- type HasuraConfig
- type HasuraInputValidationPayload
- type HasuraTriggerPayload
- type Header
- type NhostClient
- type NhostConfig
- type Response
- type TokenType
- type Variable
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrBreachingAbuseLimit error = errors.New("breaching abuse limit")
)
View Source
var ResponseCodeMap = map[ErrorType]int{ ErrorTypeJSONMarshal: http.StatusBadRequest, ErrorTypeJSONUnmarshal: http.StatusBadRequest, ErrorTypeJWTExpired: http.StatusUnauthorized, ErrorTypeUnauthorized: http.StatusUnauthorized, ErrorTypePermissionDenied: http.StatusForbidden, ErrorTypeTokenRefresh: http.StatusConflict, ErrorTypeInvalidResponse: http.StatusInternalServerError, ErrorTypeBadResponse: http.StatusInternalServerError, ErrorTypeBadRequest: http.StatusBadRequest, ErrorTypeBadGateway: http.StatusBadGateway, ErrorTypeRequestFailed: http.StatusBadRequest, ErrorTypeDoesNotExist: http.StatusNotFound, ErrorTypeInvalidKey: http.StatusBadRequest, ErrorTypeKeyNotFound: http.StatusNotFound, ErrorTypeRecordNotFound: http.StatusNotFound, ErrorTypeInvalidAccountConfiguration: http.StatusBadRequest, ErrorTypeInvalidProjectConfiguration: http.StatusBadRequest, ErrorTypeInvalidToken: http.StatusBadRequest, ErrorTypeEmailFailed: http.StatusInternalServerError, }
Functions ¶
This section is empty.
Types ¶
type APIResponse ¶
type Authorization ¶ added in v1.1.8
type Claims ¶ added in v1.1.11
type Claims struct { Hasura HasuraClaims `json:"https://hasura.io/jwt/claims"` jwt.RegisteredClaims }
type ClientType ¶
type ClientType string
const ( HTTPClientType ClientType = "HTTPClient" GithubClientType ClientType = "GithubClient" VercelClientType ClientType = "VercelClient" VaultClientType ClientType = "VaultClient" HasuraClientType ClientType = "HasuraClient" GraphQLClientType ClientType = "GraphQLClient" )
type CustomHeader ¶
type Error ¶
type Error struct { Error error `json:"error"` Message string `json:"message"` Type ErrorType `json:"type"` Source ErrorSource `json:"source"` }
func ParseExternal ¶
func (*Error) GenerateMessage ¶
type ErrorSource ¶
type ErrorSource string
const ( ErrorSourceHTTP ErrorSource = "http" ErrorSourceGraphQL ErrorSource = "graphql" ErrorSourceHermes ErrorSource = "hermes" ErrorSourceMailer ErrorSource = "mailer" ErrorSourceVault ErrorSource = "vault" ErrorSourceNhost ErrorSource = "nhost" ErrorSourceGo ErrorSource = "go" ErrorSourceSystem ErrorSource = "system" ErrorSourceGithub ErrorSource = "github" ErrorSourceVercel ErrorSource = "vercel" )
type ErrorType ¶
type ErrorType string
const ( ErrorTypeBase64Encode ErrorType = "Base64Encode" ErrorTypeBase64Decode ErrorType = "Base64Decode" ErrorTypeJSONMarshal ErrorType = "JSONMarshal" ErrorTypeJSONUnmarshal ErrorType = "JSONUnmarshal" ErrorTypeJWTExpired ErrorType = "JWTExpired" ErrorTypePermissionDenied ErrorType = "PermissionDenied" ErrorTypeTokenRefresh ErrorType = "TokenRefresh" ErrorTypeInvalidResponse ErrorType = "InvalidResponse" ErrorTypeBadResponse ErrorType = "BadResponse" ErrorTypeBadRequest ErrorType = "BadRequest" ErrorTypeBadGateway ErrorType = "BadGateway" ErrorTypeRequestFailed ErrorType = "RequestFailed" ErrorTypeDoesNotExist ErrorType = "DoesNotExist" ErrorTypeInvalidKey ErrorType = "InvalidKey" ErrorTypeKeyNotFound ErrorType = "KeyNotFound" ErrorTypeRecordNotFound ErrorType = "RecordNotFound" ErrorTypeInvalidToken ErrorType = "InvalidToken" ErrorTypeInvalidAccountConfiguration ErrorType = "InvalidAccountConfiguration" ErrorTypeInvalidProjectConfiguration ErrorType = "InvalidProjectConfiguration" ErrorTypeEmailFailed ErrorType = "EmailFailed" )
func (*ErrorType) GetStatusCode ¶
type GQL2Config ¶ added in v1.1.8
type GQL2Config struct { Type ClientType BaseURL string Authorization *Authorization Logger *logrus.Logger }
type GQLClient ¶
type GQLClient struct { *graphql.Client BaseURL string Authorization string Headers []Header CustomHeaders []CustomHeader ErrorHandler func(*GQLClient, error) error RedoRequestOnError bool // contains filtered or unexported fields }
func NewGQLClient ¶
type GQLClient2 ¶ added in v1.1.8
type GQLClient2 struct { *graphql.Client BaseURL string Authorization *Authorization // contains filtered or unexported fields }
func NewGQLClient2 ¶ added in v1.1.8
func NewGQLClient2(config *GQL2Config) *GQLClient2
type HTTPClient ¶
type HTTPClient struct { *http.Client BaseURL string Authorization string CustomHeaders []CustomHeader ResponseHandler func(*http.Response) error Type ClientType // contains filtered or unexported fields }
func NewHTTPClient ¶
func NewHTTPClient(config *HTTPConfig) *HTTPClient
func (*HTTPClient) Run ¶
func (c *HTTPClient) Run(ctx context.ServiceContext, req *http.Request, response interface{}) error
type HTTPConfig ¶
type HTTPConfig struct { Type ClientType BaseURL string Authorization string Headers []Header CustomHeaders []CustomHeader Logger *logrus.Logger ResponseHandler func(*http.Response) error }
type HasuraActionRequestPayload ¶
type HasuraActionRequestPayload struct { Action struct { Name string `json:"name"` } `json:"action"` Input struct { Args interface{} `json:"args"` } `json:"input"` }
type HasuraActionResponse ¶ added in v1.1.11
type HasuraActionResponse struct { Message string `json:"message"` Extensions *HasuraActionsResponseExtensions `json:"extensions,omitempty"` }
type HasuraActionsResponseExtensions ¶ added in v1.1.11
type HasuraClaims ¶ added in v1.1.11
type HasuraClaims struct { AllowedRoles []string `json:"x-hasura-allowed-roles,omitempty"` DefaultRole string `json:"x-hasura-default-role,omitempty"` UserID string `json:"x-hasura-user-id,omitempty"` UserEmail string `json:"x-hasura-user-email,omitempty"` IsAnonymous string `json:"x-hasura-user-is-anonymous,omitempty"` }
type HasuraClient ¶
type HasuraClient struct { *graphql.Client BaseURL string Authorization string Headers []Header CustomHeaders []CustomHeader // contains filtered or unexported fields }
func NewHasuraClient ¶
func NewHasuraClient(config *HasuraConfig) *HasuraClient
func (*HasuraClient) Do ¶
func (c *HasuraClient) Do(ctx context.ServiceContext, req *graphql.Request, resp interface{}) error
type HasuraConfig ¶
type HasuraInputValidationPayload ¶ added in v1.1.11
type HasuraInputValidationPayload struct {
Data struct {
Input interface{} `json:"input"`
} `json:"data"`
}
type HasuraTriggerPayload ¶
type HasuraTriggerPayload struct { Event struct { Op string `json:"op"` SessionVariables HasuraClaims `json:"session_variables"` Data struct { New interface{} `json:"new"` Old interface{} `json:"old"` } `json:"data"` } `json:"event"` }
type Header ¶
type Header string
const ( // Standard HTTP headers AuthorizationHeader Header = "Authorization" ContentTypeHeader Header = "Content-Type" TokenHeader Header = "x-envsecrets-token" OrgIDHeader Header = "x-envsecrets-org-id" HasuraWebhookSecret Header = "X-Hasura-Webhook-Secret" // Hasura headers XHasuraAdminSecretHeader Header = "x-hasura-admin-secret" // Github headers AcceptHeader Header = "Accept" VaultTokenHeader Header = "X-Vault-Token" VaultNamespaceHeader Header = "X-Vault-Namespace" )
type NhostClient ¶
type NhostClient struct { *http.Client Authorization string CustomHeaders []CustomHeader ResponseHandler func(*http.Response) error BaseURL string // contains filtered or unexported fields }
func NewNhostClient ¶
func NewNhostClient(config *NhostConfig) *NhostClient
func (*NhostClient) Run ¶
func (c *NhostClient) Run(ctx context.ServiceContext, req *http.Request, response interface{}) error
type NhostConfig ¶
type Variable ¶
type Variable string
const ( // API constants API Variable = "API" // Nhost constants NHOST_ADMIN_SECRET Variable = "NHOST_ADMIN_SECRET" NHOST_JWT_SECRET Variable = "NHOST_JWT_SECRET" NHOST_WEBHOOK_SECRET Variable = "NHOST_WEBHOOK_SECRET" NHOST_AUTH_URL Variable = "NHOST_AUTH_URL" NHOST_STORAGE_URL Variable = "NHOST_STORAGE_URL" NHOST_FUNCTIONS_URL Variable = "NHOST_FUNCTIONS_URL" NHOST_GRAPHQL_URL Variable = "NHOST_GRAPHQL_URL" )
Click to show internal directories.
Click to hide internal directories.