Skip to content

Commit

Permalink
fix travel deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGANGLOFF committed Apr 8, 2024
1 parent 6bf1360 commit 19365ca
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
GOOGLE_API_KEY="AIzaSyAuFLAY6DH36pKwjlJpGNetrGwx4Lt491E"
GOOGLE_API_KEY=AIzaSyAuFLAY6DH36pKwjlJpGNetrGwx4Lt491E
10 changes: 4 additions & 6 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/travel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"
rocket = { version = "0.5.0", features = ["json"] }
common = {path = '../../common'}
serde_json = "1.0.114"
dotenv = "0.15.0"
dotenv_codegen = "0.15.0"
reqwest = { version = "0.12.2", features = ["json"] }
serde = { version = "1.0.197", features = ["derive"] }
anyhow = "1.0.81"
2 changes: 0 additions & 2 deletions services/travel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ mod structure;

#[get("/service/travel/<localisation1>/<localisation2>/<transport_types>")]
async fn index(localisation1: String, localisation2: String, transport_types: String) -> Json<Vec<RouteInformations>> {
// TODO : préciser dans la doc api la séparation en virgules
// type possible : bicycling, driving, walking, transit, motorcycle.
let transport_types_vec: Vec<&str> = transport_types.split(',').collect();

let result = get_google_routes(&localisation1, &localisation2, &transport_types_vec).await.unwrap();
Expand Down
5 changes: 2 additions & 3 deletions services/travel/src/structure.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::env;
use anyhow::Context;
use serde::{Serialize, Deserialize};
use serde_json::{from_value, Value, Error};
use dotenv_codegen::dotenv;

#[derive(Serialize, Deserialize, Debug)]
pub struct Root {
Expand Down Expand Up @@ -111,8 +111,7 @@ pub fn exploit_routes(value: Value, mode: String) -> Result<RouteInformations, E
}

pub async fn get_google_routes(depart: &str, arrivee: &str, modes: &[&str]) -> Result<Vec<RouteInformations>, anyhow::Error> {
dotenv::dotenv().expect("Erreur de chargement du fichier .env");
let route_api_key = env::var("ROUTE_API_KEY").expect("ROUTE_API_KEY doit être défini");
let route_api_key = dotenv!("GOOGLE_API_KEY").to_string();
let mut routes: Vec<RouteInformations> = Vec::new();

for mode in modes {
Expand Down

0 comments on commit 19365ca

Please sign in to comment.