Documentation ¶
Index ¶
- Constants
- type CreateWebhookRequest
- type CreateWebhookResponse
- type DeleteWebhookRequest
- type GetSupportedNounsResponse
- type GetSupportedVerbsResponse
- type GetWebhookRequest
- type GetWebhookResponse
- type ListWebhooksResponse
- type Noun
- type Payload
- type Service
- func (s Service) Config() config.WebhookServiceConfig
- func (s Service) CreateWebhook(ctx context.Context, request CreateWebhookRequest) (*CreateWebhookResponse, error)
- func (s Service) DeleteWebhook(ctx context.Context, request DeleteWebhookRequest) error
- func (s Service) GetSupportedNouns() GetSupportedNounsResponse
- func (s Service) GetSupportedVerbs() GetSupportedVerbsResponse
- func (s Service) GetWebhook(ctx context.Context, request GetWebhookRequest) (*GetWebhookResponse, error)
- func (s Service) ListWebhooks(ctx context.Context) (*ListWebhooksResponse, error)
- func (s Service) PublishWebhook(c *gin.Context, noun Noun, verb Verb, payloadReader io.Reader)
- func (s Service) Status() framework.Status
- func (s Service) Type() framework.Type
- type Storage
- func (whs *Storage) DeleteWebhook(ctx context.Context, noun, verb string) error
- func (whs *Storage) GetWebhook(ctx context.Context, noun, verb string) (*Webhook, error)
- func (whs *Storage) ListWebhooks(ctx context.Context) ([]Webhook, error)
- func (whs *Storage) StoreWebhook(ctx context.Context, noun, verb string, webhook Webhook) error
- type Verb
- type Webhook
Constants ¶
View Source
const ( Credential = Noun("Credential") DID = Noun("DID") Manifest = Noun("Manifest") Schema = Noun("SchemaID") Presentation = Noun("Presentation") Application = Noun("Application") Submission = Noun("Submission") )
Supported Nouns
View Source
const ( BatchCreate = Verb("BatchCreate") Create = Verb("Create") Delete = Verb("Delete") )
Supported Verbs
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateWebhookRequest ¶
type CreateWebhookRequest struct { Noun Noun `json:"noun" validate:"required"` Verb Verb `json:"verb" validate:"required"` URL string `json:"url" validate:"required"` }
func (CreateWebhookRequest) IsValid ¶
func (cwr CreateWebhookRequest) IsValid() bool
type CreateWebhookResponse ¶
type CreateWebhookResponse struct {
Webhook Webhook `json:"webhook"`
}
type DeleteWebhookRequest ¶
type DeleteWebhookRequest struct { Noun Noun `json:"noun" validate:"required"` Verb Verb `json:"verb" validate:"required"` URL string `json:"url" validate:"required"` }
func (DeleteWebhookRequest) IsValid ¶
func (cwr DeleteWebhookRequest) IsValid() bool
type GetSupportedNounsResponse ¶
type GetSupportedNounsResponse struct {
Nouns []Noun `json:"nouns,omitempty"`
}
type GetSupportedVerbsResponse ¶
type GetSupportedVerbsResponse struct {
Verbs []Verb `json:"verbs,omitempty"`
}
type GetWebhookRequest ¶
type GetWebhookResponse ¶
type GetWebhookResponse struct {
Webhook Webhook `json:"webhook"`
}
type ListWebhooksResponse ¶
type ListWebhooksResponse struct {
Webhooks []Webhook `json:"webhooks,omitempty"`
}
type Noun ¶
type Noun string
In the context of webhooks, it's common to use noun.verb notation to describe events, such as "credential.create" or "schema.delete".
type Payload ¶
type Payload struct { Noun Noun `json:"noun" validate:"required"` Verb Verb `json:"verb" validate:"required"` URL string `json:"url" validate:"required"` Data json.RawMessage `json:"data,omitempty"` }
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewWebhookService ¶
func NewWebhookService(config config.WebhookServiceConfig, s storage.ServiceStorage) (*Service, error)
func (Service) Config ¶
func (s Service) Config() config.WebhookServiceConfig
func (Service) CreateWebhook ¶
func (s Service) CreateWebhook(ctx context.Context, request CreateWebhookRequest) (*CreateWebhookResponse, error)
func (Service) DeleteWebhook ¶
func (s Service) DeleteWebhook(ctx context.Context, request DeleteWebhookRequest) error
DeleteWebhook deletes a webhook from the storage by removing a given DIDWebID from the list of URLs associated with the webhook. If there are no URLs left in the list, the entire webhook is deleted from storage.
func (Service) GetSupportedNouns ¶
func (s Service) GetSupportedNouns() GetSupportedNounsResponse
func (Service) GetSupportedVerbs ¶
func (s Service) GetSupportedVerbs() GetSupportedVerbsResponse
func (Service) GetWebhook ¶
func (s Service) GetWebhook(ctx context.Context, request GetWebhookRequest) (*GetWebhookResponse, error)
func (Service) ListWebhooks ¶
func (s Service) ListWebhooks(ctx context.Context) (*ListWebhooksResponse, error)
ListWebhooks returns all webhooks in storage.
func (Service) PublishWebhook ¶
TODO: consider returning an error to be handled by the gin middleware
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
func NewWebhookStorage ¶
func NewWebhookStorage(db storage.ServiceStorage) (*Storage, error)
func (*Storage) DeleteWebhook ¶
func (*Storage) GetWebhook ¶
func (*Storage) ListWebhooks ¶
Click to show internal directories.
Click to hide internal directories.