Skip to main content

get

Attribute Macro get 

Source
#[get]
Expand description

Shorthand for #[orpc::route(method = "GET", path = "...")].

§Syntax

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

§With streaming data type

#[orpc::get("/stream", data = "StreamEvent")]
async fn stream_events() -> Sse<impl Stream<Item = Event>> {
    // data takes a string literal for IDE support
}