cowboy_stream:info - Handle a message for a stream


info(StreamID, Info, State) -> {Commands, State}

StreamID :: cowboy_stream:stream_id()
Info     :: any()
Commands :: cowboy_stream:commands()
State    - opaque

Handle a message for a stream.

This function should be called by all stream handlers. It will propagate the event to the next configured stream handler. Handlers do not have to propagate events that have been fully handled.



The stream ID.


The event received.


The commands to be executed.


The state for the next stream handler.

Return value

A list of commands and an opaque state is returned.

The list of commands returned should be included in the commands returned from the current stream handler. It can be modified if necessary.

The state should be stored in the current stream handler's state and passed to cowboy_stream when necessary. The state should be treated as opaque.


  • 2.0: Function introduced.


Propagate an event to the next stream handler
info(StreamID, Info, State=#state{next=Next0}) ->
    MyCommands = my_commands(),
    {Commands, Next} = cowboy_stream:info(StreamID, Info, Next0),
    {MyCommands ++ Commands, #state{next=Next}}.

See also

cowboy_stream(3), cowboy_stream:init(3), cowboy_stream:data(3), cowboy_stream:terminate(3), cowboy_stream:early_error(3)

Cowboy 2.11 Function Reference


Version select

Like my work? Donate!

Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and is fantastic:

Recurring payment options are also available via GitHub Sponsors. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.