Skip to content

Commit

Permalink
feat: clippy it
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzdong committed Apr 17, 2024
1 parent e641abb commit 5a0e3da
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ bytes = "1.0"
cookie = "0.18"
futures = "0.3"
futures-util = "0.3"
headers = "0.3"
headers = "0.4"
http-body-util = "0.1"
hyper = { version="1.0", features=["server", "http1", "http2"] }
hyper = { version="1", features=["server", "http1", "http2"] }
hyper-util = { version = "0.1", features=["tokio", "server-auto"] }
lazy_static = "1.4"
mime = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion src/extracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl IntoResponse for ParamsRejection {
fn into_response(self) -> Response {
LieResponse::new(
StatusCode::BAD_REQUEST,
"path param parse error".to_string(),
format!("path param parse error, {}", self.0),
)
.into()
}
Expand Down
2 changes: 0 additions & 2 deletions src/middleware/default_headers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::convert::TryFrom;

use crate::http::{
self,
header::{HeaderMap, HeaderName, HeaderValue},
Expand Down
13 changes: 7 additions & 6 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::net::SocketAddr;

use bytes::Bytes;
use cookie::Cookie;
use headers::{Header, HeaderMapExt};
use http_body_util::BodyExt;
use hyper::http;
use hyper::http::{HeaderName, HeaderValue};
Expand Down Expand Up @@ -35,7 +36,7 @@ pub trait LieRequest {
fn get_header<K>(&self, header: K) -> Result<&HeaderValue, Error>
where
HeaderName: From<K>;
// fn get_typed_header<T: Header + Send + 'static>(&self) -> Result<T, Error>;
fn get_typed_header<T: Header + Send + 'static>(&self) -> Result<T, Error>;

async fn read_body(&mut self) -> Result<Bytes, Error>;
async fn read_form<T: DeserializeOwned>(&mut self) -> Result<T, Error>;
Expand Down Expand Up @@ -86,11 +87,11 @@ impl LieRequest for Request {
Ok(value)
}

// fn get_typed_header<T: Header + Send + 'static>(&self) -> Result<T, Error> {
// self.headers()
// .typed_get::<T>()
// .ok_or_else(|| invalid_header(T::name().as_str()))
// }
fn get_typed_header<T: Header + Send + 'static>(&self) -> Result<T, Error> {
self.headers()
.typed_get::<T>()
.ok_or_else(|| invalid_header(T::name().as_str()))
}

fn get_cookie(&self, name: &str) -> Result<String, Error> {
let cookie = self.get_header(hyper::header::COOKIE)?;
Expand Down
1 change: 0 additions & 1 deletion src/response.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::convert::TryFrom;
use std::{borrow::Cow, convert::Infallible};

use bytes::Bytes;
Expand Down
1 change: 0 additions & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,3 @@ impl Default for App {
pub fn server_id() -> &'static str {
&SERVER_ID
}

4 changes: 3 additions & 1 deletion src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ pub struct Html {

impl Html {
pub fn new(body: impl Into<Bytes>) -> Self {
Html { body: Full::new(body.into()) }
Html {
body: Full::new(body.into()),
}
}
}

Expand Down
1 change: 0 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(dead_code)]

use std::convert::TryFrom;
use std::future::Future;
use std::pin::Pin;

Expand Down

0 comments on commit 5a0e3da

Please sign in to comment.