fix: redis, /get & /post parsing #15
2 changed files with 2 additions and 8 deletions
|
@ -45,7 +45,7 @@ pub enum AppError {
|
||||||
},
|
},
|
||||||
|
|
||||||
#[display(fmt = "UTF8")]
|
#[display(fmt = "UTF8")]
|
||||||
Utf8Error(std::str::Utf8Error),
|
Utf8Error(#[from] std::str::Utf8Error),
|
||||||
|
|
||||||
#[display(fmt = "IDK")]
|
#[display(fmt = "IDK")]
|
||||||
UnknownBody {
|
UnknownBody {
|
||||||
|
|
|
@ -5,7 +5,6 @@ pub mod qs_parser;
|
||||||
use crate::ingest_protocol::NMJsonPacket;
|
use crate::ingest_protocol::NMJsonPacket;
|
||||||
use crate::web_server::app_error::AppError;
|
use crate::web_server::app_error::AppError;
|
||||||
|
|
||||||
use bstr::ByteSlice;
|
|
||||||
use ntex::http::{HttpMessage, StatusCode};
|
use ntex::http::{HttpMessage, StatusCode};
|
||||||
use ntex::util::Bytes;
|
use ntex::util::Bytes;
|
||||||
use ntex::web::types::State;
|
use ntex::web::types::State;
|
||||||
|
@ -50,12 +49,7 @@ pub async fn device_handler<'a>(
|
||||||
Err(error) => json_error = Some(error),
|
Err(error) => json_error = Some(error),
|
||||||
},
|
},
|
||||||
"application/x-www-form-urlencoded" => {
|
"application/x-www-form-urlencoded" => {
|
||||||
let body = match std::str::from_utf8(body.as_ref()) {
|
let body = std::str::from_utf8(body.as_ref())?;
|
||||||
Ok(body) => body,
|
|
||||||
Err(error) => {
|
|
||||||
return Err(AppError::Utf8Error(error));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
match qs_parser::parse_nm_qs_format(body).await {
|
match qs_parser::parse_nm_qs_format(body).await {
|
||||||
DarkCat09 marked this conversation as resolved
Outdated
|
|||||||
Ok(qs_body) => {
|
Ok(qs_body) => {
|
||||||
real_body = Some(NMJsonPacket {
|
real_body = Some(NMJsonPacket {
|
||||||
|
|
Loading…
Reference in a new issue
Может быть всё-таки
std::str::from_utf8
используешь? Я не хочу работать с не utf-8 данными, так что заменять невалидные вещи на � не лучшее решение.