This crate builds all the assets for the routinator web UI by storing them in a Vec of bytearrays that can be served by Hyper or another web serving crate.
The library has two public functions: get_endpoints()
, returning the Vec and
ui_resource(PATH)
that will return the UI resource.
```rust use hyper::{Body, Request, Response};
const BASEURL: &str = "/ui"; const CATCHALL_URL: &str = "index.html";
pub fn processrequest(req: Request) -> Response { let path = std::path::Path::new(req.uri().path()); if let Ok(p) = path.stripprefix(BASEURL) { match routinatorui::endpoints::uiresource(p) { Some(endpoint) => serve(endpoint.content, endpoint.contenttype), None => { // In order to have the frontend handle all routing and queryparams under BASEURL, // all unknown URLs that start with /ui will route to the catchall url defined here. // // Note that we could be smarter about this and do a (somewhat convoluted) regex on // the requested URL to figure out if it makes sense as a search prefix url. if let Some(default) = routinatorui::endpoints::uiresource(std::path::Path::new(CATCHALLURL)) { serve(default.content, default.contenttype) } else { super::notfound() } } } } else { // The requested URL did not start with BASEURL, so we're returning 404. super::notfound() } }
fn serve(data: &'static [u8], ctype: &'static [u8]) -> Response
{ Response::builder() .header("Content-Type", ctype) .body(data.into()) .unwrap() } ```Please do not use cargo publish
directly on this crate, or bump the version of this create in Cargo.toml
manually!
All versioning (and code generation) is done automatically for this crate by its parent repository, the Vue App.
If you need to bump the version of this crate, git checkout
its parent at github
and issue:
npm version [major|minor|patch] -m <MESSAGE>
Where you can specify patch
, minor
or major
to bump the, well, patch, minor or major version respectively. This will take
care of the git (release) branches, the git tags, the version in Cargo.toml in this crate and the version in package.json of its
parent.
A new release, whether it is patch, minor or major will be deployed to routinator.nlnetlabs.nl
automatically by the github
Actions CI.
You can always refer to a local crate with the well-known mechanisms (including a { path = ".." }
argument in the Cargo.toml
line for this crate in routinator. If you make changes in the parent repo (the Vue App) and compile routinator, you should see
the local changes.
Also, a .tar.gz file is created for every push to the main
branch by github Actions and can be downloaded from there.