MCPcopy Create free account
hub / github.com/ElementsProject/lightning / into_response

Method into_response

plugins/rest-plugin/src/structs.rs:37–49  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

35
36impl IntoResponse for AppError {
37 fn into_response(self) -> Response {
38 let (status, error_message) = match self {
39 AppError::Unauthorized(err) => (StatusCode::UNAUTHORIZED, err),
40 AppError::Forbidden(err) => (StatusCode::FORBIDDEN, err),
41 AppError::NotFound(err) => (StatusCode::NOT_FOUND, err),
42 AppError::MethodNotAllowed(err) => (StatusCode::METHOD_NOT_ALLOWED, err),
43 AppError::InternalServerError(err) => (StatusCode::INTERNAL_SERVER_ERROR, err),
44 AppError::NotAcceptable(err) => (StatusCode::NOT_ACCEPTABLE, err),
45 };
46
47 let body = Json(json!(error_message));
48 (status, body).into_response()
49 }
50}
51
52impl std::fmt::Display for AppError {

Callers 2

convert_json_to_responseFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected