cargo fmt
This commit is contained in:
+2
-4
@@ -16,9 +16,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
println!("App: {app:?}");
|
||||
|
||||
let auth = catapult::service::auth::Auth {
|
||||
app: app.clone()
|
||||
};
|
||||
let auth = catapult::service::auth::Auth { app: app.clone() };
|
||||
let token = match auth.get_token().await {
|
||||
Ok(token) => token,
|
||||
Err(err) => {
|
||||
@@ -32,7 +30,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let mut svc = catapult::service::Service {
|
||||
app: app.clone(),
|
||||
token
|
||||
token,
|
||||
};
|
||||
|
||||
loop {
|
||||
|
||||
+14
-19
@@ -1,6 +1,6 @@
|
||||
pub struct Service {
|
||||
pub app: crate::app::App,
|
||||
pub token: textsender_models::token::Login
|
||||
pub token: textsender_models::token::Login,
|
||||
}
|
||||
|
||||
impl Service {
|
||||
@@ -30,7 +30,7 @@ impl Service {
|
||||
|
||||
pub mod auth {
|
||||
pub struct Auth {
|
||||
pub app: crate::app::App
|
||||
pub app: crate::app::App,
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -63,7 +63,8 @@ pub mod auth {
|
||||
println!("Payload: {payload:?}");
|
||||
|
||||
match client.post(api_url).json(&payload).send().await {
|
||||
Ok(response) => match response.status() {
|
||||
Ok(response) => {
|
||||
match response.status() {
|
||||
reqwest::StatusCode::OK => {
|
||||
println!("Response: {response:?}");
|
||||
match response.text().await {
|
||||
@@ -79,7 +80,9 @@ pub mod auth {
|
||||
match j.get("data") {
|
||||
Some(serde_json::Value::Array(lrs)) => {
|
||||
if lrs.is_empty() {
|
||||
Err(std::io::Error::other("Error response is empty"))
|
||||
Err(std::io::Error::other(
|
||||
"Error response is empty",
|
||||
))
|
||||
} else {
|
||||
let lr = lrs[0].clone();
|
||||
let ll: textsender_models::token::LoginResult = match serde_json::from_value(lr) { Ok(lr) => lr,
|
||||
@@ -91,33 +94,25 @@ pub mod auth {
|
||||
// Ok(textsender_models::token::LoginResult::default())
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
Err(std::io::Error::other("Error parsing response"))
|
||||
_ => Err(std::io::Error::other(
|
||||
"Error parsing response",
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
Err(std::io::Error::other(err.to_string()))
|
||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
Err(std::io::Error::other(err))
|
||||
Err(err) => Err(std::io::Error::other(err)),
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
Err(std::io::Error::other("Error getting token"))
|
||||
_ => Err(std::io::Error::other("Error getting token")),
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
Err(std::io::Error::other(err.to_string()))
|
||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user