webhook

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2023 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartHTTPApi

func StartHTTPApi(provider provider.Provider, startedChan chan struct{}, readTimeout, writeTimeout time.Duration, providerPort string)

StartHTTPApi starts a HTTP server given any provider. the function takes an optional channel as input which is used to signal that the server has started. The server will listen on port `providerPort`. The server will respond to the following endpoints: - / (GET): initialization, negotiates headers and returns the domain filter - /records (GET): returns the current records - /records (POST): applies the changes - /adjustendpoints (POST): executes the AdjustEndpoints method

Types

type WebhookProvider

type WebhookProvider struct {
	DomainFilter endpoint.DomainFilter
	// contains filtered or unexported fields
}

func NewWebhookProvider

func NewWebhookProvider(u string) (*WebhookProvider, error)

func (WebhookProvider) AdjustEndpoints

func (p WebhookProvider) AdjustEndpoints(e []*endpoint.Endpoint) ([]*endpoint.Endpoint, error)

AdjustEndpoints will call the provider doing a POST on `/adjustendpoints` which will return a list of modified endpoints based on a provider specific requirement. This method returns an empty slice in case there is a technical error on the provider's side so that no endpoints will be considered.

func (WebhookProvider) ApplyChanges

func (p WebhookProvider) ApplyChanges(ctx context.Context, changes *plan.Changes) error

ApplyChanges will make a POST to remoteServerURL/records with the changes

func (WebhookProvider) GetDomainFilter

func (p WebhookProvider) GetDomainFilter() endpoint.DomainFilter

GetDomainFilter make calls to get the serialized version of the domain filter

func (WebhookProvider) Records

func (p WebhookProvider) Records(ctx context.Context) ([]*endpoint.Endpoint, error)

Records will make a GET call to remoteServerURL/records and return the results

type WebhookServer

type WebhookServer struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳