diff --git a/src/http_client.rs b/src/http_client.rs index 1f9dae3..930df5b 100644 --- a/src/http_client.rs +++ b/src/http_client.rs @@ -7,6 +7,15 @@ pub struct HttpResponse { pub status_body: String, } +impl HttpResponse { + pub fn has_valid_response_code(&self) -> bool { + self.status_code == 200 + || self.status_code == 201 + || self.status_code == 400 + || self.status_code == 422 + } +} + #[derive(Debug, Clone)] pub struct HttpClientError(String); diff --git a/src/main.rs b/src/main.rs index 807d8a0..5e6f3de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -178,11 +178,7 @@ async fn main() -> Result<(), Box> { } } - if response.status_code == 200 - || response.status_code == 201 - || response.status_code == 400 - || response.status_code == 422 - { + if response.has_valid_response_code() { consumer.commit_message(&msg, CommitMode::Async)?; } else { warn!(