Create a simple test_registry binary which just dumps out JSON at the moment

This gives Contaminate something to talk to, at least while I'm on the plane ^_^
This commit is contained in:
R Tyler Croy 2020-02-01 08:02:56 -08:00
parent 688e0cbe86
commit df8c932a0c
No known key found for this signature in database
GPG Key ID: E5C92681BEF6CEA2
2 changed files with 37 additions and 0 deletions

View File

@ -4,6 +4,10 @@ version = "0.1.0"
authors = ["R. Tyler Croy <rtyler@brokenco.de>"]
edition = "2018"
[[bin]]
name = "test-registry"
path = "src/test_registry/main.rs"
[dependencies]
# Used for serving the website
tide = "~0.5.1"

33
src/test_registry/main.rs Normal file
View File

@ -0,0 +1,33 @@
/**
* The test_registry is a simple service which just responds with some canned
* JSON responses
*/
extern crate pretty_env_logger;
extern crate tide;
use async_std::task;
use log::*;
use tide::Request;
async fn generic_json(req: Request<()>) -> String {
info!("Received request to: {}", req.uri());
format!(r#"{{"url" : "{}"}}"#, req.uri())
}
fn main() -> Result<(), std::io::Error> {
pretty_env_logger::init();
task::block_on(async {
let mut app = tide::new();
app.at("/").get(generic_json);
app.at("*").get(generic_json);
app.listen("127.0.0.1:2345").await?;
Ok(())
})
}
#[cfg(test)]
mod tests {
}