Module rocketjson_data::api[][src]

Expand description

Api

Should be returned by the endpoints in order to achieve a Json response

Example

  • Code
#[derive(serde::Serialize)]
pub struct TestResponse {
   data: String
}

#[post("/test")]
pub fn test() -> rocketjson::ApiResponse<RegisterResponse> {
     rocketjson::ApiResponse::new(
         rocket::http::Status::Ok, RegisterResponse {
         data: String::from("test")
     })
}
  • Response (200 OK)
{
     data: "test"
}

Re-exports

pub use response::ApiResponse;
pub use response_err::ApiResponseErr;

Modules

Response

ApiResponseErr