Skip to main content

Module macros

Module macros 

Source
Expand description

Macros for HTTP handlers.

These macros simplify the common pattern of sending an RPC request and converting the response to an HTTP response.

§Type flow

oneshot_request(req)  -> Option<T>
rpc_request!(...)     -> AppResult<T>      (= Result<T, AppError>)
jsonify_rpc!(...)     -> AppResult<Json<T>> (= Result<Json<T>, AppError>)

The Option<T> from oneshot_request represents channel status:

  • Some(T) - response received
  • None - channel dropped (converted to AppError::ChannelDropped)

Note: T is often itself an Option<U>, where None means “no data available” (serialized as null). This is distinct from channel failure.