style: cleanup UTF8 error throwing code
This commit is contained in:
parent
803acce7e9
commit
19a4e0c299
2 changed files with 2 additions and 8 deletions
|
@ -45,7 +45,7 @@ pub enum AppError {
|
|||
},
|
||||
|
||||
#[display(fmt = "UTF8")]
|
||||
Utf8Error(std::str::Utf8Error),
|
||||
Utf8Error(#[from] std::str::Utf8Error),
|
||||
|
||||
#[display(fmt = "IDK")]
|
||||
UnknownBody {
|
||||
|
|
|
@ -5,7 +5,6 @@ pub mod qs_parser;
|
|||
use crate::ingest_protocol::NMJsonPacket;
|
||||
use crate::web_server::app_error::AppError;
|
||||
|
||||
use bstr::ByteSlice;
|
||||
use ntex::http::{HttpMessage, StatusCode};
|
||||
use ntex::util::Bytes;
|
||||
use ntex::web::types::State;
|
||||
|
@ -50,12 +49,7 @@ pub async fn device_handler<'a>(
|
|||
Err(error) => json_error = Some(error),
|
||||
},
|
||||
"application/x-www-form-urlencoded" => {
|
||||
let body = match std::str::from_utf8(body.as_ref()) {
|
||||
Ok(body) => body,
|
||||
Err(error) => {
|
||||
return Err(AppError::Utf8Error(error));
|
||||
}
|
||||
};
|
||||
let body = std::str::from_utf8(body.as_ref())?;
|
||||
match qs_parser::parse_nm_qs_format(body).await {
|
||||
Ok(qs_body) => {
|
||||
real_body = Some(NMJsonPacket {
|
||||
|
|
Loading…
Reference in a new issue