Skip to content

Commit

Permalink
Adapted to changes in agama-lib's base_http_client
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Aug 14, 2024
1 parent 6d15184 commit d8f957f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
6 changes: 2 additions & 4 deletions rust/agama-cli/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ impl AuthHTTPClient {

auth_body.insert("password", password);

eprintln!("get_jwt asks url: {}", self.api.base_url);
let response = self.api.post_response("/auth", &auth_body).await?;
let body = response.json::<HashMap<String, String>>().await?;
let value = body.get("token");
let response = self.api.post::<HashMap<String, String>>("/auth", &auth_body).await?;
let value = response.get("token");

if let Some(token) = value {
return Ok(token.clone());
Expand Down
2 changes: 1 addition & 1 deletion rust/agama-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ async fn run_command(cli: Cli) -> Result<(), ServiceError> {
Commands::Logs(subcommand) => run_logs_cmd(subcommand).await?,
Commands::Download { url } => crate::profile::download(&url, std::io::stdout())?,
Commands::Auth(subcommand) => {
let mut client = BaseHTTPClient::bare()?;
let mut client = BaseHTTPClient::default();

client.base_url = cli
.opts
Expand Down
9 changes: 0 additions & 9 deletions rust/agama-lib/src/base_http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ impl Default for BaseHTTPClient {
}

impl BaseHTTPClient {
// Provides new client with no specialities like authorization headers or so.
// If needed, there is place for helpers like "self::to_authorized" or so.
pub fn bare() -> Result<Self, ServiceError> {
Ok(Self {
client: reqwest::Client::new(),
base_url: API_URL.to_string(),
})
}

/// Uses `localhost`, authenticates with [`AuthToken`].
pub fn new() -> Result<Self, ServiceError> {
Ok(Self {
Expand Down

0 comments on commit d8f957f

Please sign in to comment.