feat(conf): add config param playground_path

This commit is contained in:
librelois 2021-05-30 00:22:13 +02:00
parent 3d9e3ffe49
commit d2c46fbd06
2 changed files with 19 additions and 14 deletions

View file

@ -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<String>,
@ -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,

View file

@ -277,18 +277,16 @@ impl GvaModule {
);
let conf_clone = conf.clone();
let graphql_playground =
warp::path::path(conf.path.clone())
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,
)),
.subscription_endpoint(
&format!("/{}", &conf_clone.subscriptions_path,),
),
))
});