From caab54960af1b832f327d483006ec658069c976b Mon Sep 17 00:00:00 2001 From: Tpt Date: Thu, 2 Apr 2020 19:52:07 +0200 Subject: [PATCH] Server: it is not useful to add the host to the HTML UI --- server/src/main.rs | 20 +++++--------------- server/templates/query.html | 2 +- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index eaa1bf61..67d8597b 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -61,24 +61,18 @@ where let addr = matches.value_of("bind").unwrap().to_owned(); println!("Listening for requests at http://{}", &addr); - start_server(addr.to_string(), move |request| { + start_server(addr, move |request| { content_encoding::apply( request, - handle_request(request, repository.connection().unwrap(), &addr), + handle_request(request, repository.connection().unwrap()), ) .with_unique_header("Server", SERVER) }) } -fn handle_request( - request: &Request, - mut connection: R, - host: &str, -) -> Response { +fn handle_request(request: &Request, mut connection: R) -> Response { match (request.url().as_str(), request.method()) { - ("/", "GET") => { - Response::html(HTML_ROOT_PAGE.replace("{{endpoint}}", &format!("//{}/query", host))) - } + ("/", "GET") => Response::html(HTML_ROOT_PAGE), ("/", "POST") => { if let Some(body) = request.data() { if let Some(content_type) = request.header("Content-Type") { @@ -260,11 +254,7 @@ mod tests { } fn exec(request: Request) { - let response = handle_request( - &request, - MemoryRepository::default().connection().unwrap(), - "localhost", - ); + let response = handle_request(&request, MemoryRepository::default().connection().unwrap()); let mut body = String::default(); request .data() diff --git a/server/templates/query.html b/server/templates/query.html index 7e8a95e9..04effa5d 100644 --- a/server/templates/query.html +++ b/server/templates/query.html @@ -15,7 +15,7 @@ var yasqe = YASQE(document.getElementById("yasqe"), { sparql: { showQueryButton: true, - endpoint: "{{endpoint}}" + endpoint: "/query" } }); var yasr = YASR(document.getElementById("yasr"), {