mirror of
https://github.com/poem-web/poem.git
synced 2026-01-25 04:18:25 +00:00
clippy clean
This commit is contained in:
@@ -21,7 +21,7 @@ use tokio::{spawn, time::sleep};
|
||||
|
||||
#[handler]
|
||||
fn hello(Path(name): Path<String>) -> String {
|
||||
format!("hello: {}", name)
|
||||
format!("hello: {name}")
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
@@ -55,7 +55,7 @@ async fn main() -> Result<(), std::io::Error> {
|
||||
{
|
||||
Ok(result) => result.rustls_key,
|
||||
Err(err) => {
|
||||
eprintln!("failed to issue certificate: {}", err);
|
||||
eprintln!("failed to issue certificate: {err}");
|
||||
sleep(Duration::from_secs(60 * 5)).await;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ mod tests {
|
||||
for case in invalid_cases {
|
||||
let result = Duration::parse_from_json(Some(Value::String(case.to_string())));
|
||||
dbg!(&result);
|
||||
assert!(result.is_err(), "Should have failed for: {}", case);
|
||||
assert!(result.is_err(), "Should have failed for: {case}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ pub fn build_poem_req(req: HttpRequest) -> Result<poem::Request> {
|
||||
let local_addr = if let Some(client_ip) = headers.get("cf-connecting-ip") {
|
||||
let client_ip = client_ip
|
||||
.to_str()
|
||||
.map_err(|e| worker::Error::RustError(format!("{}", e)))?;
|
||||
.map_err(|e| worker::Error::RustError(format!("{e}")))?;
|
||||
|
||||
let ip_addr = client_ip
|
||||
.parse::<IpAddr>()
|
||||
.map_err(|e| worker::Error::RustError(format!("{}", e)))?;
|
||||
.map_err(|e| worker::Error::RustError(format!("{e}")))?;
|
||||
|
||||
let addr = SocketAddr::new(ip_addr, 0);
|
||||
|
||||
|
||||
@@ -92,17 +92,17 @@ impl<E: RustEmbed + Send + Sync> Endpoint for EmbeddedFilesEndpoint<E> {
|
||||
if path.is_empty() && !original_end_with_slash {
|
||||
Ok(Response::builder()
|
||||
.status(StatusCode::FOUND)
|
||||
.header(LOCATION, format!("{}/", original_path))
|
||||
.header(LOCATION, format!("{original_path}/"))
|
||||
.finish())
|
||||
} else if original_end_with_slash {
|
||||
let path = format!("{}index.html", path);
|
||||
let path = format!("{path}index.html");
|
||||
EmbeddedFileEndpoint::<E>::new(&path).call(req).await
|
||||
} else if E::get(path).is_some() {
|
||||
EmbeddedFileEndpoint::<E>::new(path).call(req).await
|
||||
} else if E::get(&format!("{}/index.html", path)).is_some() {
|
||||
} else if E::get(&format!("{path}/index.html")).is_some() {
|
||||
Ok(Response::builder()
|
||||
.status(StatusCode::FOUND)
|
||||
.header(LOCATION, format!("{}/", original_path))
|
||||
.header(LOCATION, format!("{original_path}/"))
|
||||
.finish())
|
||||
} else {
|
||||
EmbeddedFileEndpoint::<E>::new(path).call(req).await
|
||||
|
||||
Reference in New Issue
Block a user