Attribute Macro dropshot_endpoint::channel
source · #[channel]
Expand description
As with endpoint
, this attribute turns a handler function into a
Dropshot endpoint, but first wraps the handler function in such a way
that is spawned asynchronously and given the upgraded connection of
the given protocol
(i.e. WEBSOCKETS
).
The first argument still must be a RequestContext<_>
.
The last argument passed to the handler function must be a
WebsocketConnection
.
The function must return a
WebsocketChannelResult
(which is a general-purpose Result<(), Box<dyn Error + Send + Sync + 'static>>
). Returned error values will be written to the RequestContext’s
log.
ⓘ
#[dropshot::channel { protocol = WEBSOCKETS, path = "/my/ws/channel/{id}" }]