Use common rust formatting
This commit is contained in:
parent
698f36518d
commit
aebcde3808
20
src/main.rs
20
src/main.rs
@ -1,11 +1,8 @@
|
||||
use axum::{
|
||||
http::StatusCode,
|
||||
response::{IntoResponse, Response},
|
||||
routing::get,
|
||||
Router,
|
||||
response::{
|
||||
IntoResponse,
|
||||
Response,
|
||||
},
|
||||
http::StatusCode,
|
||||
};
|
||||
|
||||
use std::net::SocketAddr;
|
||||
@ -20,7 +17,7 @@ async fn main() {
|
||||
let arg = if let Some(arg) = args.next() {
|
||||
arg
|
||||
} else {
|
||||
break
|
||||
break;
|
||||
};
|
||||
|
||||
match arg.as_str() {
|
||||
@ -29,10 +26,10 @@ async fn main() {
|
||||
println!("Use --listen <addr:port> bind the web service.");
|
||||
println!("Output will be on /metrics endpoint. HTTP 500 if something broke while scraping.");
|
||||
std::process::exit(0);
|
||||
},
|
||||
}
|
||||
"--listen" => {
|
||||
listen = args.next().unwrap();
|
||||
},
|
||||
}
|
||||
unknown => {
|
||||
println!("unknown option: {}", unknown);
|
||||
std::process::exit(1)
|
||||
@ -53,10 +50,11 @@ async fn main() {
|
||||
fn get_current_system() -> Result<(String, String), String> {
|
||||
let symlink = match std::fs::read_link("/run/current-system") {
|
||||
Ok(symlink) => symlink,
|
||||
Err(err) => return Err(err.to_string())
|
||||
Err(err) => return Err(err.to_string()),
|
||||
};
|
||||
|
||||
let (hash, name) = symlink.file_name()
|
||||
let (hash, name) = symlink
|
||||
.file_name()
|
||||
.ok_or_else(String::default)?
|
||||
.to_str()
|
||||
.ok_or_else(String::default)?
|
||||
@ -72,7 +70,7 @@ async fn metrics() -> Response {
|
||||
Ok((hash, name)) => (hash, name),
|
||||
Err(err) => {
|
||||
println!("failed: {}", err);
|
||||
return (StatusCode::INTERNAL_SERVER_ERROR, "").into_response()
|
||||
return (StatusCode::INTERNAL_SERVER_ERROR, "").into_response();
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user