mirror of
https://github.com/pcvolkmer/mv64e-kafka-to-rest-gateway
synced 2025-09-13 09:12:52 +00:00
refactor: move check for valid response code
This commit is contained in:
@@ -7,6 +7,15 @@ pub struct HttpResponse {
|
|||||||
pub status_body: String,
|
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)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct HttpClientError(String);
|
pub struct HttpClientError(String);
|
||||||
|
|
||||||
|
@@ -178,11 +178,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.status_code == 200
|
if response.has_valid_response_code() {
|
||||||
|| response.status_code == 201
|
|
||||||
|| response.status_code == 400
|
|
||||||
|| response.status_code == 422
|
|
||||||
{
|
|
||||||
consumer.commit_message(&msg, CommitMode::Async)?;
|
consumer.commit_message(&msg, CommitMode::Async)?;
|
||||||
} else {
|
} else {
|
||||||
warn!(
|
warn!(
|
||||||
|
Reference in New Issue
Block a user