# Routinator UI 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. ## Usage Example ```rust use hyper::{Body, Request, Response}; const BASE_URL: &str = "/ui"; const CATCH_ALL_URL: &str = "index.html"; pub fn process_request(req: Request
) -> Response { let path = std::path::Path::new(req.uri().path()); if let Ok(p) = path.strip_prefix(BASE_URL) { match routinator_ui::endpoints::ui_resource(p) { Some(endpoint) => serve(endpoint.content, endpoint.content_type), None => { // In order to have the frontend handle all routing and queryparams under BASE_URL, // all unknown URLs that start with /ui will route to the catch_all 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) = routinator_ui::endpoints::ui_resource(std::path::Path::new(CATCH_ALL_URL)) { serve(default.content, default.content_type) } else { super::not_found() } } } } else { // The requested URL did *not* start with BASE_URL, so we're returning 404. super::not_found() } } fn serve(data: &'static [u8], ctype: &'static [u8]) -> Response { Response::builder() .header("Content-Type", ctype) .body(data.into()) .unwrap() } ``` ## Building this Library 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](https://github.com/NLnetLabs/routinator-ui) and issue: `npm version [major|minor|patch] -m