MCPcopy Create free account
hub / github.com/serverlesstechnology/cqrs / command_handler

Function command_handler

demo/src/route_handler.rs:26–42  ·  view source on GitHub ↗

Serves as our command endpoint to make changes in a `BankAccount` aggregate.

(
    Path(account_id): Path<String>,
    State(state): State<ApplicationState>,
    CommandExtractor(metadata, command): CommandExtractor,
)

Source from the content-addressed store, hash-verified

24
25// Serves as our command endpoint to make changes in a `BankAccount` aggregate.
26pub async fn command_handler(
27 Path(account_id): Path<String>,
28 State(state): State<ApplicationState>,
29 CommandExtractor(metadata, command): CommandExtractor,
30) -> Response {
31 match state
32 .cqrs
33 .execute_with_metadata(&account_id, command, metadata)
34 .await
35 {
36 Ok(()) => StatusCode::NO_CONTENT.into_response(),
37 Err(err) => {
38 println!("Error: {err:#?}\n");
39 (StatusCode::BAD_REQUEST, err.to_string()).into_response()
40 }
41 }
42}

Callers 1

lambda_command_handlerFunction · 0.85

Calls 2

execute_with_metadataMethod · 0.80
into_responseMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…