Documentation ¶
Overview ¶
Package web implements the webhooks integration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewWebhookRegistryRPC ¶
func NewWebhookRegistryRPC(webhooks WebhookRegistry, templates TemplateStore) ttnpb.ApplicationWebhookRegistryServer
NewWebhookRegistryRPC returns a new webhook registry gRPC server.
Types ¶
type ControllableSink ¶
ControllableSink is a controllable Sink.
type DownlinksConfig ¶
type DownlinksConfig struct { PublicAddress string `name:"public-address" description:"Public address of the HTTP webhooks frontend"` PublicTLSAddress string `name:"public-tls-address" description:"Public address of the HTTPS webhooks frontend"` }
DownlinksConfig defines the configuration for the webhook downlink queue operations. For public addresses, the TLS version is preferred when present.
type Format ¶
type Format struct { formatters.Formatter Name string ContentType string }
Format is a format to use for web-based frontends.
type HTTPClientSink ¶
HTTPClientSink contains an HTTP client to make outgoing requests.
type QueuedSink ¶
QueuedSink is a ControllableSink with queue.
type TemplateStore ¶
type TemplateStore interface { // GetTemplate returns the template with the given identifiers. GetTemplate(ctx context.Context, req *ttnpb.GetApplicationWebhookTemplateRequest) (*ttnpb.ApplicationWebhookTemplate, error) // ListTemplates returns the available templates. ListTemplates(ctx context.Context, req *ttnpb.ListApplicationWebhookTemplatesRequest) (*ttnpb.ApplicationWebhookTemplates, error) }
TemplateStore contains the webhook templates.
type TemplatesConfig ¶
type TemplatesConfig struct { Static map[string][]byte `name:"-"` Directory string `name:"directory" description:"Retrieve the webhook templates from the filesystem"` URL string `name:"url" description:"Retrieve the webhook templates from a web server"` LogoBaseURL string `name:"logo-base-url" description:"The base URL for the logo storage"` HTTPClient *http.Client `name:"-"` }
TemplatesConfig defines the configuration for the webhook templates registry.
func (TemplatesConfig) NewTemplateStore ¶
func (c TemplatesConfig) NewTemplateStore() (TemplateStore, error)
NewTemplateStore returns a TemplateStore based on the configuration.
type WebhookRegistry ¶
type WebhookRegistry interface { // Get returns the webhook by its identifiers. Get(ctx context.Context, ids ttnpb.ApplicationWebhookIdentifiers, paths []string) (*ttnpb.ApplicationWebhook, error) // List returns all webhooks of the application. List(ctx context.Context, ids ttnpb.ApplicationIdentifiers, paths []string) ([]*ttnpb.ApplicationWebhook, error) // Set creates, updates or deletes the webhook by its identifiers. Set(ctx context.Context, ids ttnpb.ApplicationWebhookIdentifiers, paths []string, f func(*ttnpb.ApplicationWebhook) (*ttnpb.ApplicationWebhook, []string, error)) (*ttnpb.ApplicationWebhook, error) }
WebhookRegistry is a store for webhooks.
type Webhooks ¶
type Webhooks interface { ttnweb.Registerer Registry() WebhookRegistry }
Webhooks is an interface for registering incoming webhooks for downlink and creating a subscription to outgoing webhooks for upstream data.
func NewWebhooks ¶
func NewWebhooks(ctx context.Context, server io.Server, registry WebhookRegistry, target Sink, downlinks DownlinksConfig) (Webhooks, error)
NewWebhooks returns a new Webhooks.