Server: it is not useful to add the host to the HTML UI

pull/26/head
Tpt 5 years ago
parent c970d10ec3
commit caab54960a
  1. 20
      server/src/main.rs
  2. 2
      server/templates/query.html

@ -61,24 +61,18 @@ where
let addr = matches.value_of("bind").unwrap().to_owned(); let addr = matches.value_of("bind").unwrap().to_owned();
println!("Listening for requests at http://{}", &addr); println!("Listening for requests at http://{}", &addr);
start_server(addr.to_string(), move |request| { start_server(addr, move |request| {
content_encoding::apply( content_encoding::apply(
request, request,
handle_request(request, repository.connection().unwrap(), &addr), handle_request(request, repository.connection().unwrap()),
) )
.with_unique_header("Server", SERVER) .with_unique_header("Server", SERVER)
}) })
} }
fn handle_request<R: RepositoryConnection>( fn handle_request<R: RepositoryConnection>(request: &Request, mut connection: R) -> Response {
request: &Request,
mut connection: R,
host: &str,
) -> Response {
match (request.url().as_str(), request.method()) { match (request.url().as_str(), request.method()) {
("/", "GET") => { ("/", "GET") => Response::html(HTML_ROOT_PAGE),
Response::html(HTML_ROOT_PAGE.replace("{{endpoint}}", &format!("//{}/query", host)))
}
("/", "POST") => { ("/", "POST") => {
if let Some(body) = request.data() { if let Some(body) = request.data() {
if let Some(content_type) = request.header("Content-Type") { if let Some(content_type) = request.header("Content-Type") {
@ -260,11 +254,7 @@ mod tests {
} }
fn exec(request: Request) { fn exec(request: Request) {
let response = handle_request( let response = handle_request(&request, MemoryRepository::default().connection().unwrap());
&request,
MemoryRepository::default().connection().unwrap(),
"localhost",
);
let mut body = String::default(); let mut body = String::default();
request request
.data() .data()

@ -15,7 +15,7 @@
var yasqe = YASQE(document.getElementById("yasqe"), { var yasqe = YASQE(document.getElementById("yasqe"), {
sparql: { sparql: {
showQueryButton: true, showQueryButton: true,
endpoint: "{{endpoint}}" endpoint: "/query"
} }
}); });
var yasr = YASR(document.getElementById("yasr"), { var yasr = YASR(document.getElementById("yasr"), {

Loading…
Cancel
Save