Skip to main content

orpc

Attribute Macro orpc 

Source
#[orpc]
Expand description

Annotate a plain Axum handler to register its metadata with rorpc.

The function is left completely unchanged — it remains a valid Axum handler. Two inventory::submit! calls are added alongside it: one for [rorpc::HandlerMetadata] (used by contract generation) and one for [rorpc::HandlerRegistration] (used by router!).

§Syntax

#[orpc(method = "POST", path = "/planet/list")]
async fn list_planets(State(db): State<Db>) -> Json<Vec<Planet>> {
    Json(db.list().await)
}

§Arguments

  • method — HTTP method string ("GET", "post", etc.), normalised to uppercase. Required.
  • path — Route path string (e.g. "/planet/list"). Required.
  • stream_event — Name of the SSE event type for streaming handlers. Optional.