Skip to content

Commit

Permalink
change user agent
Browse files Browse the repository at this point in the history
  • Loading branch information
Gianmarco Fraccaroli committed Feb 8, 2024
1 parent b09b96c commit cb31424
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ impl ApplicationServer {

Router::new()
.route("/faucet/setting", get(faucet_handler::faucet_settings))
.route("/faucet/challenge/:player_id", get(faucet_handler::request_challenge))
.route(
"/faucet/challenge/:player_id",
get(faucet_handler::request_challenge),
)
.route("/faucet", post(faucet_handler::request_transfer))
.with_state(faucet_state)
.merge(Router::new().route(
Expand Down
18 changes: 11 additions & 7 deletions src/handler/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use namada_sdk::{
},
Namada,
};
use reqwest::header::USER_AGENT;

use crate::{
dto::faucet::{
Expand Down Expand Up @@ -51,13 +52,16 @@ pub async fn request_challenge(
State(mut state): State<FaucetState>,
Path(player_id): Path<String>,
) -> Result<Json<FaucetResponseDto>, ApiError> {
let is_player = match reqwest::get(format!(
"https://{}/api/v1/player/exists/{}",
state.webserver_host, player_id
))
.await
.map(|response| response.status().is_success())
{
let client = reqwest::Client::new();
let req = client
.get(format!(
"https://{}/api/v1/player/exists/{}",
state.webserver_host, player_id
))
.header(USER_AGENT, "Mozilla/5.0 (X11; CrOS x86_64 8172.45.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.64 Safari/537.36")
.send()
.await;
let is_player = match req.map(|response| response.status().is_success()) {
Ok(is_success) if is_success => true,
_ => false,
};
Expand Down

0 comments on commit cb31424

Please sign in to comment.