milenkovicm commented on code in PR #2059:
URL: 
https://github.com/apache/datafusion-ballista/pull/2059#discussion_r3598963085


##########
ballista/scheduler/src/api/handlers.rs:
##########
@@ -227,6 +229,48 @@ pub enum PlanFormat {
     Metrics,
 }
 
+/// A handler for GET requests to the root (`/`).
+/// It redirects to 
`https://nightlies.apache.org/datafusion/ballista/tui/<BALLISTA_VERSION>/`
+/// forwarding any query parameters
+pub async fn get_root(
+    header_map: HeaderMap,
+    Query(mut params): Query<HashMap<String, String>>,
+) -> Result<Redirect, (StatusCode, String)> {
+    const NIGHTLIES_URL: &str = 
"https://nightlies.apache.org/datafusion/ballista/tui";;
+
+    let ballista_scheduler_url =
+        params.remove("ballista_scheduler_url").unwrap_or_else(|| {
+            let default_scheduler_url = "localhost:50050";
+            let scheduler_url = header_map
+                .get("host")
+                .map(|hv| hv.to_str().unwrap_or(default_scheduler_url))
+                .unwrap_or(default_scheduler_url);
+            let proto = header_map
+                .get("x-forwarded-proto")
+                .and_then(|v| v.to_str().ok())
+                .unwrap_or("http");
+            format!("{proto}://{scheduler_url}")
+        });
+
+    let mut query_string = String::new();
+    query_string.push_str(&format!(
+        "ballista_scheduler_url={}",
+        url_escape::encode_query(&ballista_scheduler_url)
+    ));
+
+    for (k, v) in params.iter() {
+        query_string.push_str(&format!(
+            "&{}={}",
+            url_escape::encode_query(k),
+            url_escape::encode_query(v)
+        ));
+    }
+
+    let target = format!("{NIGHTLIES_URL}/{BALLISTA_VERSION}/?{query_string}");

Review Comment:
   it would be great if we could make target configurable and forward to 
NIGHTLIES_URL only if there is no such configuration, this would allow users to 
have its own version of tui deployed somewhere else 



##########
ballista/scheduler/src/api/handlers.rs:
##########
@@ -227,6 +229,48 @@ pub enum PlanFormat {
     Metrics,
 }
 
+/// A handler for GET requests to the root (`/`).
+/// It redirects to 
`https://nightlies.apache.org/datafusion/ballista/tui/<BALLISTA_VERSION>/`
+/// forwarding any query parameters
+pub async fn get_root(
+    header_map: HeaderMap,
+    Query(mut params): Query<HashMap<String, String>>,
+) -> Result<Redirect, (StatusCode, String)> {
+    const NIGHTLIES_URL: &str = 
"https://nightlies.apache.org/datafusion/ballista/tui";;
+
+    let ballista_scheduler_url =

Review Comment:
   should we also take into account `external_host` from scheduler 
configuration g?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to