diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-06-21 11:51:40 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-06-21 11:51:40 -0700 |
commit | 256b297886352fd0e732183e00d476bb32bc663e (patch) | |
tree | 29b36eacee790e6d2356c61ed25ed6f7250f578e /rust | |
parent | cb63f207258071ade7f300dc63e9ed8cb98a1353 (diff) | |
download | fatcat-256b297886352fd0e732183e00d476bb32bc663e.tar.gz fatcat-256b297886352fd0e732183e00d476bb32bc663e.zip |
no more default/mangled HTTP status codes
Diffstat (limited to 'rust')
-rw-r--r-- | rust/fatcat-api/README.md | 2 | ||||
-rw-r--r-- | rust/fatcat-api/api.yaml | 19 | ||||
-rw-r--r-- | rust/fatcat-api/api/swagger.yaml | 63 | ||||
-rw-r--r-- | rust/fatcat-api/src/client.rs | 56 | ||||
-rw-r--r-- | rust/fatcat-api/src/models.rs | 11 | ||||
-rw-r--r-- | rust/fatcat-api/src/server.rs | 56 | ||||
-rw-r--r-- | rust/src/api_server.rs | 37 | ||||
-rw-r--r-- | rust/src/bin/fatcatd.rs | 5 |
8 files changed, 130 insertions, 119 deletions
diff --git a/rust/fatcat-api/README.md b/rust/fatcat-api/README.md index 4b40f7ee..572bcbc5 100644 --- a/rust/fatcat-api/README.md +++ b/rust/fatcat-api/README.md @@ -13,7 +13,7 @@ To see how to make this your own, look here: [README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md) - API version: 0.1.0 -- Build date: 2018-06-20T01:30:08.472Z +- Build date: 2018-06-21T18:49:41.205Z This autogenerated project defines an API crate `fatcat` which contains: * An `Api` trait defining the API in Rust. diff --git a/rust/fatcat-api/api.yaml b/rust/fatcat-api/api.yaml index 253cec04..2326f225 100644 --- a/rust/fatcat-api/api.yaml +++ b/rust/fatcat-api/api.yaml @@ -158,14 +158,15 @@ definitions: #format: custom volume: type: string - pages: - type: string issue: type: string example: "12" + pages: + type: string publisher: type: string language: + description: "Two-letter RFC1766/ISO639-1 language code, with extensions" type: string contribs: type: array @@ -327,7 +328,7 @@ x-entity-responses: &ENTITYRESPONSES description: Not Found schema: $ref: "#/definitions/error_response" - default: + 500: description: Generic Error schema: $ref: "#/definitions/error_response" @@ -694,7 +695,7 @@ paths: description: Not Found schema: $ref: "#/definitions/error_response" - default: + 500: description: Generic Error schema: $ref: "#/definitions/error_response" @@ -715,7 +716,7 @@ paths: description: Not Found schema: $ref: "#/definitions/error_response" - default: + 500: description: Generic Error schema: $ref: "#/definitions/error_response" @@ -737,7 +738,7 @@ paths: description: Bad Request schema: $ref: "#/definitions/error_response" - default: + 500: description: Generic Error schema: $ref: "#/definitions/error_response" @@ -763,7 +764,7 @@ paths: description: Not Found schema: $ref: "#/definitions/error_response" - default: + 500: description: Generic Error schema: $ref: "#/definitions/error_response" @@ -789,7 +790,7 @@ paths: description: Not Found schema: $ref: "#/definitions/error_response" - default: + 500: description: Generic Error schema: $ref: "#/definitions/error_response" @@ -806,7 +807,7 @@ paths: description: Success schema: $ref: "#/definitions/stats_response" - default: + 500: description: Generic Error schema: $ref: "#/definitions/error_response" diff --git a/rust/fatcat-api/api/swagger.yaml b/rust/fatcat-api/api/swagger.yaml index 3740cbb2..1a719322 100644 --- a/rust/fatcat-api/api/swagger.yaml +++ b/rust/fatcat-api/api/swagger.yaml @@ -57,7 +57,7 @@ paths: uppercase_operation_id: "CREATE_CONTAINER" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -118,7 +118,7 @@ paths: uppercase_operation_id: "CREATE_CONTAINER_BATCH" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -170,7 +170,7 @@ paths: uppercase_operation_id: "GET_CONTAINER" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -222,7 +222,7 @@ paths: uppercase_operation_id: "LOOKUP_CONTAINER" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -280,7 +280,7 @@ paths: uppercase_operation_id: "CREATE_CREATOR" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -341,7 +341,7 @@ paths: uppercase_operation_id: "CREATE_CREATOR_BATCH" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -393,7 +393,7 @@ paths: uppercase_operation_id: "GET_CREATOR" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -447,7 +447,7 @@ paths: uppercase_operation_id: "GET_CREATOR_RELEASES" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -499,7 +499,7 @@ paths: uppercase_operation_id: "LOOKUP_CREATOR" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -557,7 +557,7 @@ paths: uppercase_operation_id: "CREATE_FILE" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -618,7 +618,7 @@ paths: uppercase_operation_id: "CREATE_FILE_BATCH" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -670,7 +670,7 @@ paths: uppercase_operation_id: "GET_FILE" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -722,7 +722,7 @@ paths: uppercase_operation_id: "LOOKUP_FILE" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -780,7 +780,7 @@ paths: uppercase_operation_id: "CREATE_RELEASE" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -841,7 +841,7 @@ paths: uppercase_operation_id: "CREATE_RELEASE_BATCH" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -893,7 +893,7 @@ paths: uppercase_operation_id: "GET_RELEASE" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -947,7 +947,7 @@ paths: uppercase_operation_id: "GET_RELEASE_FILES" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -999,7 +999,7 @@ paths: uppercase_operation_id: "LOOKUP_RELEASE" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -1057,7 +1057,7 @@ paths: uppercase_operation_id: "CREATE_WORK" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -1118,7 +1118,7 @@ paths: uppercase_operation_id: "CREATE_WORK_BATCH" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -1170,7 +1170,7 @@ paths: uppercase_operation_id: "GET_WORK" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -1224,7 +1224,7 @@ paths: uppercase_operation_id: "GET_WORK_RELEASES" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -1267,7 +1267,7 @@ paths: uppercase_operation_id: "GET_EDITOR" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -1310,7 +1310,7 @@ paths: uppercase_operation_id: "GET_EDITOR_CHANGELOG" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -1359,7 +1359,7 @@ paths: uppercase_operation_id: "CREATE_EDITGROUP" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -1413,7 +1413,7 @@ paths: uppercase_operation_id: "GET_EDITGROUP" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -1466,7 +1466,7 @@ paths: uppercase_operation_id: "ACCEPT_EDITGROUP" uppercase_data_type: "ERRORRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -1500,7 +1500,7 @@ paths: uppercase_operation_id: "GET_STATS" uppercase_data_type: "STATSRESPONSE" producesJson: true - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" @@ -1722,13 +1722,14 @@ definitions: $ref: "#/definitions/release_contrib" language: type: "string" + description: "Two-letter RFC1766/ISO639-1 language code, with extensions" publisher: type: "string" + pages: + type: "string" issue: type: "string" example: "12" - pages: - type: "string" volume: type: "string" isbn13: @@ -2197,7 +2198,7 @@ x-entity-responses: description: "Not Found" schema: $ref: "#/definitions/error_response" - default: + 500: description: "Generic Error" schema: $ref: "#/definitions/error_response" diff --git a/rust/fatcat-api/src/client.rs b/rust/fatcat-api/src/client.rs index 809fd1d6..b94d6f42 100644 --- a/rust/fatcat-api/src/client.rs +++ b/rust/fatcat-api/src/client.rs @@ -197,7 +197,7 @@ impl Api for Client { Ok(AcceptEditgroupResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -262,7 +262,7 @@ impl Api for Client { Ok(CreateContainerResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -327,7 +327,7 @@ impl Api for Client { Ok(CreateContainerBatchResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -392,7 +392,7 @@ impl Api for Client { Ok(CreateCreatorResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -457,7 +457,7 @@ impl Api for Client { Ok(CreateCreatorBatchResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -515,7 +515,7 @@ impl Api for Client { Ok(CreateEditgroupResponse::BadRequest(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -580,7 +580,7 @@ impl Api for Client { Ok(CreateFileResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -645,7 +645,7 @@ impl Api for Client { Ok(CreateFileBatchResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -710,7 +710,7 @@ impl Api for Client { Ok(CreateReleaseResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -775,7 +775,7 @@ impl Api for Client { Ok(CreateReleaseBatchResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -840,7 +840,7 @@ impl Api for Client { Ok(CreateWorkResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -905,7 +905,7 @@ impl Api for Client { Ok(CreateWorkBatchResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -965,7 +965,7 @@ impl Api for Client { Ok(GetContainerResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -1025,7 +1025,7 @@ impl Api for Client { Ok(GetCreatorResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -1085,7 +1085,7 @@ impl Api for Client { Ok(GetCreatorReleasesResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -1145,7 +1145,7 @@ impl Api for Client { Ok(GetEditgroupResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -1202,7 +1202,7 @@ impl Api for Client { Ok(GetEditorResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -1259,7 +1259,7 @@ impl Api for Client { Ok(GetEditorChangelogResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -1319,7 +1319,7 @@ impl Api for Client { Ok(GetFileResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -1379,7 +1379,7 @@ impl Api for Client { Ok(GetReleaseResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -1439,7 +1439,7 @@ impl Api for Client { Ok(GetReleaseFilesResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -1488,7 +1488,7 @@ impl Api for Client { Ok(GetStatsResponse::Success(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -1548,7 +1548,7 @@ impl Api for Client { Ok(GetWorkResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -1608,7 +1608,7 @@ impl Api for Client { Ok(GetWorkReleasesResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -1671,7 +1671,7 @@ impl Api for Client { Ok(LookupContainerResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -1734,7 +1734,7 @@ impl Api for Client { Ok(LookupCreatorResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -1797,7 +1797,7 @@ impl Api for Client { Ok(LookupFileResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; @@ -1860,7 +1860,7 @@ impl Api for Client { Ok(LookupReleaseResponse::NotFound(body)) } - 0 => { + 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::<models::ErrorResponse>(&buf)?; diff --git a/rust/fatcat-api/src/models.rs b/rust/fatcat-api/src/models.rs index 15247ce6..fd9e8658 100644 --- a/rust/fatcat-api/src/models.rs +++ b/rust/fatcat-api/src/models.rs @@ -463,6 +463,7 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub contribs: Option<Vec<models::ReleaseContrib>>, + /// Two-letter RFC1766/ISO639-1 language code, with extensions #[serde(rename = "language")] #[serde(skip_serializing_if = "Option::is_none")] pub language: Option<String>, @@ -471,14 +472,14 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub publisher: Option<String>, - #[serde(rename = "issue")] - #[serde(skip_serializing_if = "Option::is_none")] - pub issue: Option<String>, - #[serde(rename = "pages")] #[serde(skip_serializing_if = "Option::is_none")] pub pages: Option<String>, + #[serde(rename = "issue")] + #[serde(skip_serializing_if = "Option::is_none")] + pub issue: Option<String>, + #[serde(rename = "volume")] #[serde(skip_serializing_if = "Option::is_none")] pub volume: Option<String>, @@ -546,8 +547,8 @@ impl ReleaseEntity { contribs: None, language: None, publisher: None, - issue: None, pages: None, + issue: None, volume: None, isbn13: None, doi: None, diff --git a/rust/fatcat-api/src/server.rs b/rust/fatcat-api/src/server.rs index 7eb73122..faa9e293 100644 --- a/rust/fatcat-api/src/server.rs +++ b/rust/fatcat-api/src/server.rs @@ -150,7 +150,7 @@ where AcceptEditgroupResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -254,7 +254,7 @@ where CreateContainerResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::CREATE_CONTAINER_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -360,7 +360,7 @@ where CreateContainerBatchResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::CREATE_CONTAINER_BATCH_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -466,7 +466,7 @@ where CreateCreatorResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -572,7 +572,7 @@ where CreateCreatorBatchResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::CREATE_CREATOR_BATCH_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -665,7 +665,7 @@ where CreateEditgroupResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -771,7 +771,7 @@ where CreateFileResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -877,7 +877,7 @@ where CreateFileBatchResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::CREATE_FILE_BATCH_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -983,7 +983,7 @@ where CreateReleaseResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1089,7 +1089,7 @@ where CreateReleaseBatchResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::CREATE_RELEASE_BATCH_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1195,7 +1195,7 @@ where CreateWorkResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1301,7 +1301,7 @@ where CreateWorkBatchResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_BATCH_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1391,7 +1391,7 @@ where GetContainerResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::GET_CONTAINER_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1479,7 +1479,7 @@ where GetCreatorResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1567,7 +1567,7 @@ where GetCreatorReleasesResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_RELEASES_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1655,7 +1655,7 @@ where GetEditgroupResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1733,7 +1733,7 @@ where GetEditorResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1811,7 +1811,7 @@ where GetEditorChangelogResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_CHANGELOG_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1899,7 +1899,7 @@ where GetFileResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::GET_FILE_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -1987,7 +1987,7 @@ where GetReleaseResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -2075,7 +2075,7 @@ where GetReleaseFilesResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_FILES_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -2133,7 +2133,7 @@ where GetStatsResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::GET_STATS_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -2221,7 +2221,7 @@ where GetWorkResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::GET_WORK_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -2309,7 +2309,7 @@ where GetWorkReleasesResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::GET_WORK_RELEASES_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -2393,7 +2393,7 @@ where LookupContainerResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::LOOKUP_CONTAINER_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -2477,7 +2477,7 @@ where LookupCreatorResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::LOOKUP_CREATOR_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -2561,7 +2561,7 @@ where LookupFileResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::LOOKUP_FILE_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); @@ -2645,7 +2645,7 @@ where LookupReleaseResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); - let mut response = Response::with((status::Status::from_u16(0), body_string)); + let mut response = Response::with((status::Status::from_u16(500), body_string)); response.headers.set(ContentType(mimetypes::responses::LOOKUP_RELEASE_GENERIC_ERROR.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs index c8b1f012..61005226 100644 --- a/rust/src/api_server.rs +++ b/rust/src/api_server.rs @@ -1159,17 +1159,19 @@ impl Api for Server { _context: &Context, ) -> Box<Future<Item = GetEditorChangelogResponse, Error = ApiError> + Send> { let ret = match self.editor_changelog_get_handler(username.clone()) { - Ok(entries) => - GetEditorChangelogResponse::FoundMergedChanges(entries), - Err(Error(ErrorKind::Diesel(::diesel::result::Error::NotFound), _)) => - GetEditorChangelogResponse::NotFound( - ErrorResponse { message: format!("No such editor: {}", username.clone()) }), + Ok(entries) => GetEditorChangelogResponse::FoundMergedChanges(entries), + Err(Error(ErrorKind::Diesel(::diesel::result::Error::NotFound), _)) => { + GetEditorChangelogResponse::NotFound(ErrorResponse { + message: format!("No such editor: {}", username.clone()), + }) + } Err(e) => { // TODO: dig in to error type here error!("{}", e); - GetEditorChangelogResponse::GenericError( - ErrorResponse { message: e.to_string() }) - }, + GetEditorChangelogResponse::GenericError(ErrorResponse { + message: e.to_string(), + }) + } }; Box::new(futures::done(Ok(ret))) } @@ -1180,16 +1182,19 @@ impl Api for Server { _context: &Context, ) -> Box<Future<Item = GetEditorResponse, Error = ApiError> + Send> { let ret = match self.get_editor_handler(username.clone()) { - Ok(entity) => - GetEditorResponse::FoundEditor(entity), - Err(Error(ErrorKind::Diesel(::diesel::result::Error::NotFound), _)) => - GetEditorResponse::NotFound( - ErrorResponse { message: format!("No such editor: {}", username.clone()) }), + Ok(entity) => GetEditorResponse::FoundEditor(entity), + Err(Error(ErrorKind::Diesel(::diesel::result::Error::NotFound), _)) => { + GetEditorResponse::NotFound(ErrorResponse { + message: format!("No such editor: {}", username.clone()), + }) + } Err(e) => { // TODO: dig in to error type here error!("{}", e); - GetEditorResponse::GenericError(ErrorResponse { message: e.to_string() }) - }, + GetEditorResponse::GenericError(ErrorResponse { + message: e.to_string(), + }) + } }; Box::new(futures::done(Ok(ret))) } @@ -1206,7 +1211,7 @@ impl Api for Server { GetStatsResponse::GenericError(ErrorResponse { message: e.to_string(), }) - }, + } }; Box::new(futures::done(Ok(ret))) } diff --git a/rust/src/bin/fatcatd.rs b/rust/src/bin/fatcatd.rs index 4778df9e..1e0c3e53 100644 --- a/rust/src/bin/fatcatd.rs +++ b/rust/src/bin/fatcatd.rs @@ -71,7 +71,10 @@ fn main() { } let host_port = "localhost:9411"; - info!(logger, "Starting fatcatd API server on http://{}", &host_port); + info!( + logger, + "Starting fatcatd API server on http://{}", &host_port + ); let mut chain = Chain::new(LoggerMiddleware::new(router, logger, formatter)); |