Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInstallationExists is returned if a shop that has already installed this // application attempts to install it a second time. ErrInstallationExists = errors.New("An installation already exists for this shop and application.") // ErrInvalidHMAC is returned when a request from shopify (or pretending to // be from shopify) contains an invalid HMAC signature. ErrInvalidHMAC = errors.New("The request contained an invalid HMAC - this request will be discarded.") // ErrInvalidRequestData is returned when a json.Marshal fails on the // shopify access token request struct. ErrInvalidRequestData = errors.New("The request data to be sent to shopify for an access token was invalid - please make sure your configuration settings are applied properly.") // ErrInvalidResponseData is returned when a json.Unmarshal fails on a // response from shopify ErrInvalidResponseData = errors.New("The response data returned from shopify was in an unexpected format.") // ErrBadPersistence is returned when the implementation of persistence // passed to shoauth fails for some reason. ErrBadPersistence = errors.New("The persistence passed to shoauth failed to perform an action.") )
Functions ¶
func DefaultFailureHandler ¶
DefaultFailureHandler returns an HTTP handler that simply displays a 403.
func NewShopifyOauthHandler ¶
func NewShopifyOauthHandler(successHandler http.Handler, failureHandler http.Handler, persistence ShopifyPersistence, configOptions ...func(*ShopifyConfig)) *shopifyOauthHandler
NewShopifyOauthHandler returns the middleware handler that handles Shopify oauth requests and responses. It will call successHandler.ServeHTTP on a successful installation or verification, and will call failureHandler.ServeHTTP on an unsuccessful installation or verification. The user must pass a shopifyPersistence-satisfying struct and any functions they wish to operate on the default config object.
Types ¶
type ErrShopifyHTTPRequestFailed ¶
type ErrShopifyHTTPRequestFailed struct {
// contains filtered or unexported fields
}
ErrShopifyHTTPRequestFailed is returned when an HTTP request to a shopify shop fails.
func (*ErrShopifyHTTPRequestFailed) Error ¶
func (e *ErrShopifyHTTPRequestFailed) Error() string
type ShopifyConfig ¶
type ShopifyConfig struct { ClientID string // Your app's API key RedirectURI string // If you want a different URL other than the callback on installation, put it here Scopes []string // Your app's required scopes IsEmbedded bool // If your app is embedded Webhooks map[string]string // Webhooks that should be created on installation. Scripts map[string][]string // Script tags that should be created on installation. Map is map[event][]sources }
ShopifyConfig is a structure that contains variables specific to the app that the developer is creating.
type ShopifyPersistence ¶
type ShopifyPersistence interface { InstallationExists(shopID string) bool // Checks if a shop has installed an app CreateInstallation(shopID string, accessToken string) error // Stores the installation in your app's persistence }
ShopifyPersistence contains functions that a client app must implement to help this middleware.