Skip to main content

echo

Function echo 

Source
pub async fn echo(__arg0: Json<EchoRequest>) -> Json<EchoResponse>
Expand description

Echoes back the message sent in the request.

§Arguments

  • payload - The JSON payload containing the message to be echoed.

§Returns

A JSON response containing the echoed message.

§Example

use axum::Json;
use serde_json::json;

let payload = Json(json!({ "message": "Hello, world!" }));
let response = echo(payload).await;
assert_eq!(response.echoed, "Hello, world!");