Documentation ¶
Overview ¶
Package common contains structs and methods that are shared across different gateways.
Index ¶
- Variables
- func DefaultPostActivate(rc *RouteConfig) error
- func DefaultPostStop(rc *RouteConfig) error
- func FormatWebhookEndpoint(endpoint string) string
- func GenerateFormattedURL(w *Webhook) string
- func InitRouteChannels(helper *WebhookHelper)
- func ProcessRoute(rc *RouteConfig, helper *WebhookHelper, ...) error
- func ValidateGatewayEventSource(eventSource string, parseEventSource func(string) (interface{}, error), ...) (*gateways.ValidEventSource, error)
- func ValidateWebhook(w *Webhook) error
- type Endpoint
- type RouteConfig
- type WatchPathConfig
- type Webhook
- type WebhookHelper
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNilEventSource = fmt.Errorf("event source can't be nil")
)
Functions ¶
func DefaultPostActivate ¶
func DefaultPostActivate(rc *RouteConfig) error
func DefaultPostStop ¶
func DefaultPostStop(rc *RouteConfig) error
func FormatWebhookEndpoint ¶
func GenerateFormattedURL ¶
func InitRouteChannels ¶
func InitRouteChannels(helper *WebhookHelper)
InitRouteChannels initializes route channels so they can activate and deactivate routes.
func ProcessRoute ¶
func ProcessRoute(rc *RouteConfig, helper *WebhookHelper, eventStream gateways.Eventing_StartEventSourceServer) error
func ValidateWebhook ¶
Types ¶
type Endpoint ¶
type Endpoint struct { // whether endpoint is active Active bool // data channel to receive data on this endpoint DataCh chan []byte }
endpoint contains state of an http endpoint
type RouteConfig ¶
type RouteConfig struct { Webhook *Webhook Configs map[string]interface{} EventSource *gateways.EventSource Log zerolog.Logger StartCh chan struct{} RouteActiveHandler func(writer http.ResponseWriter, request *http.Request, rc *RouteConfig) PostActivate func(rc *RouteConfig) error PostStop func(rc *RouteConfig) error }
RouteConfig contains configuration about an http route
type WatchPathConfig ¶
type WatchPathConfig struct { // Directory to watch for events Directory string `json:"directory"` // Path is relative path of object to watch with respect to the directory Path string `json:"path,omitempty"` // PathRegexp is regexp of relative path of object to watch with respect to the directory PathRegexp string `json:"pathRegexp,omitempty"` }
func (*WatchPathConfig) Validate ¶
func (c *WatchPathConfig) Validate() error
Validate validates WatchPathConfig
type Webhook ¶
type Webhook struct { // REST API endpoint Endpoint string `json:"endpoint" protobuf:"bytes,1,name=endpoint"` // Method is HTTP request method that indicates the desired action to be performed for a given resource. // See RFC7231 Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content Method string `json:"method" protobuf:"bytes,2,name=method"` // Port on which HTTP server is listening for incoming events. Port string `json:"port" protobuf:"bytes,3,name=port"` // URL is the url of the server. URL string `json:"url" protobuf:"bytes,4,name=url"` // ServerCertPath refers the file that contains the cert. ServerCertPath string `json:"serverCertPath,omitempty" protobuf:"bytes,4,opt,name=serverCertPath"` // ServerKeyPath refers the file that contains private key ServerKeyPath string `json:"serverKeyPath,omitempty" protobuf:"bytes,5,opt,name=serverKeyPath"` // contains filtered or unexported fields }
Webhook is a general purpose REST API
type WebhookHelper ¶
type WebhookHelper struct { // Mutex synchronizes ActiveServers Mutex sync.Mutex // ActiveServers keeps track of currently running http servers. ActiveServers map[string]*activeServer // ActiveEndpoints keep track of endpoints that are already registered with server and their status active or inactive ActiveEndpoints map[string]*Endpoint // RouteActivateChan handles assigning new route to server. RouteActivateChan chan *RouteConfig // RouteDeactivateChan handles deactivating existing route RouteDeactivateChan chan *RouteConfig }
WebhookHelper is a helper struct
func NewWebhookHelper ¶
func NewWebhookHelper() *WebhookHelper
NewWebhookHelper returns new webhook helper
Click to show internal directories.
Click to hide internal directories.