cloudevents v0.1.0 Cloudevents View Source
Cloudevents implementation for Elixir. This is the main module.
Link to this section Summary
Functions
Converts a HTTP request into one or more Cloudevents.
Decodes a JSON-encoded Cloudevent.
Serialize an event in HTTP binary content mode.
Encodes a Cloudevents using JSON format.
Serialize an event in HTTP structured content mode.
Link to this section Types
Link to this type
cloudevent()
View Sourcecloudevent() :: Cloudevents.Format.V_1_0.Event.t() | Cloudevents.Format.V_0_2.Event.t() | Cloudevents.Format.V_0_1.Event.t()
Link to this section Functions
Link to this function
from_http_message(http_body, http_headers)
View Sourcefrom_http_message(http_body(), http_headers()) :: {:ok, [cloudevent()]} | {:error, Cloudevents.ParseError.t()}
Converts a HTTP request into one or more Cloudevents.
Note that the HTTP request could contain more than one event (called a "batch"). Because of this, the function always returns a list of Cloudevents. Use pattern matching if you expect single events only:
with {:ok, [the_event]} = from_http_message(body, headers) do
"do something with the_event"
else
{:ok, events} -> "oops got a batch of events"
{:error, error} -> "failed to parse HTTP request: #{inspect(error)}"
end
Link to this function
from_json(json)
View Sourcefrom_json(json :: binary()) :: {:ok, cloudevent()} | {:error, %Cloudevents.Format.Decoder.DecodeError{ __exception__: term(), cause: term() }}
Decodes a JSON-encoded Cloudevent.
Link to this function
to_binary_http_message(event)
View Sourceto_binary_http_message(cloudevent()) :: {http_body(), http_headers()}
Serialize an event in HTTP binary content mode.
Encodes a Cloudevents using JSON format.
Link to this function
to_structured_http_message(event, event_format)
View Sourceto_structured_http_message(cloudevent(), event_format :: :json) :: {http_body(), http_headers()}
Serialize an event in HTTP structured content mode.