Documentation ¶
Index ¶
- Constants
- Variables
- func ApiKeyFromContext(ctx context.Context) string
- func CreateSlug(title string) string
- func ErrorCode(err error) string
- func ErrorMessage(err error) string
- func NewContextWithApiKey(ctx context.Context, key string) context.Context
- func NewContextWithSiteConfig(ctx context.Context, site *Site) context.Context
- type AWSDeploymentSettigs
- type Config
- type Deployment
- type DeploymentSettings
- type Error
- type ModelSettings
- type OutputSettings
- type Payload
- type Registry
- type RegistryService
- type RegistrySettings
- type SFTPDeploymentSettings
- type SanitizerService
- type Site
- type SiteService
- type StrapiWebhookEvents
Constants ¶
const ( ErrInternal = "internal" ErrInvalid = "invalid" ErrUnaccepted = "unaccepted" ErrRegistry = "registry" ErrSiteConfig = "site config" )
Variables ¶
var ( Commit string Version string RegistryServices map[string]func(site Site) RegistryService DeploymentTargets map[string]func(site Site, settings DeploymentSettings) (Deployment, error) Sanitizer SanitizerService )
var ReportError = func(ctx context.Context, err error, args ...interface{}) { log.Printf("error: %+v\n", err) }
ReportError is used to notify external services of error.
Functions ¶
func ApiKeyFromContext ¶
ApiKeyFromContext returns current API key from context.
func CreateSlug ¶
CreateSlug generates an url-safe string from title (or any other string) to be used as post/page slug.
func ErrorCode ¶
ErrorCode unwraps an application error and returns its code. Non-application errors always return ErrInternal.
func ErrorMessage ¶
ErrorMessage unwraps an application error and returns its message. Non-application errors always return "Internal error"
func NewContextWithApiKey ¶
NewContextWithApiKey returns a new context with given API key.
Types ¶
type AWSDeploymentSettigs ¶ added in v1.1.0
type Deployment ¶ added in v1.1.0
type Deployment interface {
Deploy() error
}
type DeploymentSettings ¶ added in v1.1.0
type DeploymentSettings struct { Enabled bool `json:"enabled,default=false"` Target string `json:"target"` // Can be: AWS, SFTP AWS AWSDeploymentSettigs `json:"aws,omitempty"` SFTP SFTPDeploymentSettings `json:"sftp,omitempty"` }
type Error ¶
type Error struct { // Machine-readable error code Code string // Human-readable error message Message string }
Error represents an application-specific error. App errors can be unwrapped to extract out the code & message.
Any non-application errors (such as a disk error) should be reported as en ErrInternal error, so the end-user should only see "internal error". These error details should be logged to the operator of application.
type ModelSettings ¶
type OutputSettings ¶
type Registry ¶
Registry type is used to hold data from registries. It's structure is Id => Filename. So from this JSON:
{ "1": "sample-post.html" }
"1" would be a key and "sample-post.html" would be a value.
type RegistryService ¶
type RegistrySettings ¶
type SFTPDeploymentSettings ¶ added in v1.2.0
type SFTPDeploymentSettings struct { Host string `json:"host"` Port *int `json:"port"` User string `json:"user"` Method string `json:"method"` Password string `json:"password,omitempty"` Key string `json:"key,omitempty"` KeyPassphrase string `json:"keyPassphrase,omitempty"` Path string `json:"path"` }
type SanitizerService ¶
type Site ¶
type Site struct { SiteName string `json:"siteName"` Service string `json:"service"` RootDir string `json:"rootDir"` OutputSettings OutputSettings `json:"outputSettings"` BuildDrafts bool `json:"buildDrafts,default=false"` DraftsUrl string `json:"draftsUrl"` Registry RegistrySettings `json:"registry"` CollectionTypes map[string]ModelSettings `json:"collectionTypes"` SingleTypes map[string]ModelSettings `json:"singleTypes"` Deployment DeploymentSettings `json:"deployment"` DraftsDeployment DeploymentSettings `json:"draftsDeployment"` }
func SiteConfigFromContext ¶
SiteConfigFromContext returns current config from context.
type SiteService ¶
type StrapiWebhookEvents ¶
type StrapiWebhookEvents int64
const ( Undefined StrapiWebhookEvents = iota Create Update Delete Publish Unpublish )
func (StrapiWebhookEvents) MarshalJSON ¶
func (event StrapiWebhookEvents) MarshalJSON() ([]byte, error)
func (StrapiWebhookEvents) String ¶
func (event StrapiWebhookEvents) String() string
func (*StrapiWebhookEvents) UnmarshalJSON ¶
func (event *StrapiWebhookEvents) UnmarshalJSON(bytes []byte) error