Documentation ¶
Overview ¶
Package webhook provides types and utility functions for handling Lyft webhooks.
Index ¶
Constants ¶
const ( RideStatusUpdated = "ride.status.updated" RideReceiptReady = "ride.receipt.ready" )
Event types.
const SandboxEventPrefix = "sandboxevent"
Variables ¶
var ErrVerify = errors.New("failed to verify request")
ErrVerify is returned by DecodeEvent if the request could not be verified to have been originating from Lyft.
Functions ¶
func Signature ¶
Signature returns the value of "X-Lyft-Signature" from an incoming webhook request header. The "sha256=" prefix will have been trimmed in the returned string.
Types ¶
type Event ¶
type Event struct { EventID string URL string Occurred time.Time EventType string // Some fields may not be set. // See details for each event type: https://developer.lyft.com/v1/docs/webhooks Detail lyft.RideDetail }
Event represents an event from a Lyft webhook. It implements json.Unmarshaler in a manner suitable for decoding incoming webhook request bodies.
func DecodeEvent ¶
DecodeEvent decodes an incoming webhook request's body and header into an Event. DecodeEvent will verify that the request was received from Lyft. The error will be ErrVerify if verification fails. The request body will always be drained and closed, even if an error is returned. Errors from draining and closing are not reported.