diff --git a/conf/src/lib.rs b/conf/src/lib.rs index 96ccd28..846a8d7 100644 --- a/conf/src/lib.rs +++ b/conf/src/lib.rs @@ -34,6 +34,8 @@ pub struct GvaConf { pub port: u16, #[serde(default = "path_default")] pub path: String, + #[serde(default = "playground_path_default")] + pub playground_path: String, #[serde(default = "subscriptions_path_default")] pub subscriptions_path: String, pub remote_host: Option, @@ -57,6 +59,10 @@ fn path_default() -> String { "gva".to_owned() } +fn playground_path_default() -> String { + "gva-playground".to_owned() +} + const fn port_default() -> u16 { 30_901 } @@ -79,6 +85,7 @@ impl Default for GvaConf { ip4: ip4_default(), ip6: Some(ip6_default()), port: port_default(), + playground_path: playground_path_default(), path: path_default(), subscriptions_path: subscriptions_path_default(), remote_host: None, diff --git a/src/lib.rs b/src/lib.rs index fe50d43..bad7d1e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -277,20 +277,18 @@ impl GvaModule { ); let conf_clone = conf.clone(); - let graphql_playground = - warp::path::path(conf.path.clone()) - .and(warp::get()) - .map(move || { - HttpResponse::builder() - .header("content-type", "text/html") - .body(async_graphql::http::playground_source( - GraphQLPlaygroundConfig::new(&format!("/{}", &conf_clone.path)) - .subscription_endpoint(&format!( - "/{}", - &conf_clone.subscriptions_path, - )), - )) - }); + let graphql_playground = warp::path::path(conf.playground_path.clone()) + .and(warp::get()) + .map(move || { + HttpResponse::builder() + .header("content-type", "text/html") + .body(async_graphql::http::playground_source( + GraphQLPlaygroundConfig::new(&format!("/{}", &conf_clone.path)) + .subscription_endpoint( + &format!("/{}", &conf_clone.subscriptions_path,), + ), + )) + }); let routes = graphql_playground .or(graphql_post)