Skip to content

Commit

Permalink
Merge pull request #65 from spiralover/refactor/app
Browse files Browse the repository at this point in the history
feat(reqwest): ability to directly deserialize error response
  • Loading branch information
Ahmard authored Sep 7, 2024
2 parents 3f11632 + 9b00d43 commit dfcfdd6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Medullah Changelog
medullah-web changelog file

## 0.19.1 (2024-09-07)
* feat(reqwest): ability to directly deserialize error response

## 0.19.0 (2024-09-07)
* refactor(rabbitmq): recreate closed channel
* feat(rabbitmq): global state is now wrapped around Arc<Mutex<>>
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "medullah-web"
version = "0.19.0"
version = "0.19.1"
edition = "2021"
license = "MIT"
description = "Micro-Framework Base on Ntex"
Expand Down
9 changes: 7 additions & 2 deletions src/helpers/reqwest.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::prelude::{AppMessage, IntoAppResult};
use crate::results::AppResult;
use reqwest::StatusCode;
use serde::de::DeserializeOwned;
use std::fmt::Display;

use crate::prelude::AppMessage;

pub struct ReqwestResponseError {
body: String,
status: StatusCode,
Expand All @@ -24,6 +25,10 @@ impl ReqwestResponseError {
pub fn body(&self) -> &String {
&self.body
}

pub fn deserialize<T: DeserializeOwned>(&self) -> AppResult<T> {
serde_json::from_str::<T>(&self.body).into_app_result()
}
}

impl Display for ReqwestResponseError {
Expand Down

0 comments on commit dfcfdd6

Please sign in to comment.