Documentation
¶
Index ¶
- Variables
- type Attempt
- type AttemptBody
- type AttemptRequest
- type AttemptResponse
- type AttemptResponseBody
- type Client
- type Config
- type ConnectionMessage
- type ConnectionMessageBody
- type ErrorAttemptBody
- type ErrorAttemptResponse
- type EventHandler
- type EventHandlerFunc
- type IncomingMessage
- type OutgoingMessage
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownID error = errors.New(unknownIDMessage)
ErrUnknownID can occur when the websocket session is expired or invalid
Functions ¶
This section is empty.
Types ¶
type Attempt ¶
type Attempt struct {
Event string `json:"type"`
Body AttemptBody `json:"body"`
}
type AttemptBody ¶
type AttemptBody struct {
Path string `json:"cli_path"`
EventID string `json:"event_id"`
AttemptId string `json:"attempt_id"`
ConnectionId string `json:"webhook_id"`
Request AttemptRequest `json:"request"`
}
type AttemptRequest ¶
type AttemptRequest struct {
Method string `json:"method"`
Timeout int64 `json:"timeout"`
DataString string `json:"data_string"`
Headers json.RawMessage `json:"headers"`
}
type AttemptResponse ¶
type AttemptResponse struct {
Event string `json:"event"`
Body AttemptResponseBody `json:"body"`
}
type AttemptResponseBody ¶
type Client ¶
type Client struct {
// URL the client connects to
URL string
CLIKey string
TeamID string
// ID sent by the client in the `Websocket-Id` header when connecting
WebSocketID string
NotifyExpired chan struct{}
// contains filtered or unexported fields
}
Client is the client used to receive webhook requests from Hookdeck and send back webhook responses from the local endpoint to Hookdeck.
func (*Client) Connected ¶
func (c *Client) Connected() <-chan struct{}
Connected returns a channel that's closed when the client has finished establishing the websocket connection.
func (*Client) ConnectionLost ¶
func (c *Client) ConnectionLost()
ConnectionLost sends NotifyExpired
func (*Client) SendMessage ¶
func (c *Client) SendMessage(msg *OutgoingMessage)
SendMessage sends a message to Hookdeck through the websocket.
type Config ¶
type Config struct {
ConnectAttemptWait time.Duration
Dialer *ws.Dialer
Log *log.Logger
// Force use of unencrypted ws:// protocol instead of wss://
NoWSS bool
PingPeriod time.Duration
PongWait time.Duration
WriteWait time.Duration
EventHandler EventHandler
}
Config contains the optional configuration parameters of a Client.
type ConnectionMessage ¶
type ConnectionMessage struct {
Event string `json:"event"`
Body ConnectionMessageBody `json:"body"`
}
type ConnectionMessageBody ¶
type ErrorAttemptBody ¶
type ErrorAttemptResponse ¶
type ErrorAttemptResponse struct {
Event string `json:"event"`
Body ErrorAttemptBody `json:"body"`
}
type EventHandler ¶
type EventHandler interface {
ProcessEvent(IncomingMessage)
}
EventHandler handles an event.
type EventHandlerFunc ¶
type EventHandlerFunc func(IncomingMessage)
EventHandlerFunc is an adapter to allow the use of ordinary functions as event handlers. If f is a function with the appropriate signature, EventHandlerFunc(f) is a EventHandler that calls f.
func (EventHandlerFunc) ProcessEvent ¶
func (f EventHandlerFunc) ProcessEvent(msg IncomingMessage)
ProcessEvent calls f(msg).
type IncomingMessage ¶
type IncomingMessage struct {
*Attempt
}
IncomingMessage represents any incoming message sent by Hookdeck.
func (*IncomingMessage) UnmarshalJSON ¶
func (m *IncomingMessage) UnmarshalJSON(data []byte) error
UnmarshalJSON deserializes incoming messages sent by Hookdeck into the appropriate structure.
type OutgoingMessage ¶
type OutgoingMessage struct {
*ErrorAttemptResponse
*AttemptResponse
*ConnectionMessage
}
OutgoingMessage represents any outgoing message sent to Hookdeck.
func (OutgoingMessage) MarshalJSON ¶
func (m OutgoingMessage) MarshalJSON() ([]byte, error)
MarshalJSON serializes outgoing messages sent to Hookdeck.