Added ability to list all domains
This commit is contained in:
parent
f7107de96b
commit
d93d4accba
1
TODO
1
TODO
@ -1,4 +1,3 @@
|
|||||||
- list existing domains
|
|
||||||
- logging
|
- logging
|
||||||
- expect statements (pretend it's "expected", not "expect")
|
- expect statements (pretend it's "expected", not "expect")
|
||||||
- map_unexpected annotation string
|
- map_unexpected annotation string
|
||||||
|
@ -288,6 +288,36 @@ where
|
|||||||
|
|
||||||
self.render_page("/domain_sync.html", response)
|
self.render_page("/domain_sync.html", response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn domains(&self) -> SvcResponse {
|
||||||
|
#[derive(Serialize)]
|
||||||
|
struct Response {
|
||||||
|
domains: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
let domains = match self.domain_manager.all_domains() {
|
||||||
|
Ok(domains) => domains,
|
||||||
|
Err(e) => {
|
||||||
|
return self.render_error_page(500, format!("failed get all domains: {e}").as_str())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let domains: Vec<domain::Name> = match domains.into_iter().try_collect() {
|
||||||
|
Ok(domains) => domains,
|
||||||
|
Err(e) => {
|
||||||
|
return self.render_error_page(500, format!("failed get all domains: {e}").as_str())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut domains: Vec<String> = domains
|
||||||
|
.into_iter()
|
||||||
|
.map(|domain| domain.as_str().to_string())
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
domains.sort();
|
||||||
|
|
||||||
|
self.render_page("/domains.html", Response { domains: domains })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_request<DomainManager>(
|
pub async fn handle_request<DomainManager>(
|
||||||
@ -385,6 +415,7 @@ where
|
|||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
(&Method::GET, "/domains.html") => svc.domains(),
|
||||||
_ => svc.render_error_page(404, "Page not found!"),
|
_ => svc.render_error_page(404, "Page not found!"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
src/service/http_tpl/domains.html
Normal file
12
src/service/http_tpl/domains.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<h2>All Domains</h2>
|
||||||
|
|
||||||
|
<p>Below are listed all domains which this Domiply instance is currently
|
||||||
|
serving</p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{{ #each data.domains }}
|
||||||
|
<li>
|
||||||
|
<a href="https://{{ this }}">{{ this }}</a>
|
||||||
|
</li>
|
||||||
|
{{ /each }}
|
||||||
|
</ul>
|
@ -29,7 +29,7 @@ been set up.</p>
|
|||||||
<p>Or you can do any of the following alternative actions:</p>
|
<p>Or you can do any of the following alternative actions:</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>List all existing domains (TODO)</li>
|
<li><a href="/domains.html">List all existing domains</a></li>
|
||||||
<li><a href="https://code.betamike.com/cryptic-io/domiply">View the Source Code</a></li>
|
<li><a href="https://code.betamike.com/cryptic-io/domiply">View the Source Code</a></li>
|
||||||
<li><a href="mailto:me@mediocregopher.com">Report a Bug</a></li>
|
<li><a href="mailto:me@mediocregopher.com">Report a Bug</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
Reference in New Issue
Block a user