endpoint

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// URL the client sends POST requests to
	URL string
	// contains filtered or unexported fields
}

Client is the client used to POST webhook requests to the local endpoint.

func NewClient

func NewClient(url string, events []string, cfg *Config) *Client

NewClient returns a new Client.

func (*Client) Post

func (c *Client) Post(webhookID string, body string, headers map[string]string) error

Post sends a message to the local endpoint.

func (*Client) SupportsEventType

func (c *Client) SupportsEventType(eventType string) bool

SupportsEventType takes an event of a webhook and compares it to the internal list of supported events

type Config

type Config struct {
	HTTPClient *http.Client

	Log *log.Logger

	ResponseHandler ResponseHandler
}

Config contains the optional configuration parameters of a Client.

type ResponseHandler

type ResponseHandler interface {
	ProcessResponse(string, *http.Response)
}

ResponseHandler handles a response from the endpoint.

type ResponseHandlerFunc

type ResponseHandlerFunc func(string, *http.Response)

ResponseHandlerFunc is an adapter to allow the use of ordinary functions as response handlers. If f is a function with the appropriate signature, ResponseHandler(f) is a ResponseHandler that calls f.

func (ResponseHandlerFunc) ProcessResponse

func (f ResponseHandlerFunc) ProcessResponse(webhookID string, resp *http.Response)

ProcessResponse calls f(webhookID, resp).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL