Z63HIZPS4WOEDXVLOLVIHNZI2IMXCFCFBIHHM65EQ7SGJRX6BVCAC
E4OBIIUBGNDXK577XK573TLN4DYLS32GJGXY6J7TOWFHESTEZZNAC
W3M3C7CCWHJWRWHULDWO45D3OFD4NL3V4OTJVIJCYRQG57Z2JTWQC
FS2NWBVN2SZB2FFPB3JSYT5URTVZEAZWMQ7QW4JUYPNJVDVAJTTQC
K4JNAJOFEJLHHWP6YSCC2U3CNK3ZPPX6EMBAVQG4VRPZWZRXMPCQC
5UNA2DEALCSRBINR27KSA6OMD6GQAXHYZ35ICQ7NB62G2XP4FT5QC
3E77DEMDLYBFJEGS2SLQKLQJQIXG2Y4TBDHAG3UKFLMKQ53CFOKQC
KFVJ3KMWXEGILN4NWIWPPX7AU65M4H4UEAUIAQL2QSXOW3B5RFGQC
RJ75MX6YMJSXYKW2YK6ZJNG2SQMPCPKICMESMC4ZD4EB2SCVJ2KAC
TWIZ7QV4GCTQK743IKZSOJCIAEX62GZHFIYGOIFCFGIBOGPSY2WAC
use rocket::http::Status;
#[tokio::test]
async fn get_landing_page() {
use rocket::local::asynchronous::Client;
let client = Client::tracked(nidobyte::rocket().await)
.await
.expect("foo");
let response = client.get("/").dispatch().await;
assert_eq!(response.status(), Status::Ok);
let body = response.into_string().await.unwrap();
assert!(body.contains("Nidobyte"));
}
use std::env;
use rocket::fs::{relative, FileServer};
use rocket_dyn_templates::Template;
#[macro_use]
extern crate rocket;
mod database;
mod repoman;
mod controllers;
mod models;
#[launch]
fn rocket() -> _ {
let repo_storage_root =
env::var("REPOSITORY_ROOT").expect("No REPOSITORY_ROOT env var exposed");
rocket::build()
.attach(database::stage())
.attach(Template::fairing())
.manage(repoman::new(repo_storage_root))
.mount("/", controllers::routes())
.mount("/", FileServer::from(relative!("static")))
}
/// this macro is lifted from the upstream unreleased code.
#[macro_export]
macro_rules! context {
($($key:ident $(: $value:expr)?),*$(,)?) => {{
use rocket::serde::ser::{Serialize, Serializer, SerializeMap};
use ::std::fmt::{Debug, Formatter};
#[allow(non_camel_case_types)]
struct ContextMacroCtxObject<$($key: Serialize),*> {
$($key: $key),*
}
#[allow(non_camel_case_types)]
impl<$($key: Serialize),*> Serialize for ContextMacroCtxObject<$($key),*> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,
{
let mut map = serializer.serialize_map(None)?;
$(map.serialize_entry(stringify!($key), &self.$key)?;)*
map.end()
}
}
use futures::executor::block_on;
use nidobyte;
#[allow(non_camel_case_types)]
impl<$($key: Debug + Serialize),*> Debug for ContextMacroCtxObject<$($key),*> {
fn fmt(&self, f: &mut Formatter<'_>) -> ::std::fmt::Result {
f.debug_struct("context!")
$(.field(stringify!($key), &self.$key))*
.finish()
}
}
ContextMacroCtxObject {
$($key $(: $value)?),*
}
}};
fn main() {
block_on(async_main())
#[test]
fn test_hello() {
use rocket::local::blocking::Client;
let client = Client::tracked(rocket()).unwrap();
let response = client.get("/").dispatch();
assert_eq!(response.status(), Status::Ok);
let body = response.into_string().unwrap();
assert!(body.contains("Hello, world!"));
}
async fn async_main() {
let rocket = nidobyte::rocket();
rocket
.await
.ignite()
.await
.expect("rocket failed to ignite")
.launch()
.await
.expect("failed to launch rocket");
use std::env;
use rocket::fs::{relative, FileServer};
use rocket::{Build, Rocket};
use rocket_dyn_templates::Template;
#[macro_use]
extern crate rocket;
mod database;
mod repoman;
mod controllers;
mod models;
pub async fn rocket() -> Rocket<Build> {
let repo_storage_root =
env::var("REPOSITORY_ROOT").expect("No REPOSITORY_ROOT env var exposed");
rocket::build()
.attach(database::stage())
.attach(Template::fairing())
.manage(repoman::new(repo_storage_root))
.mount("/", controllers::routes())
.mount("/", FileServer::from(relative!("static")))
}
/// this macro is lifted from the upstream unreleased code.
#[macro_export]
macro_rules! context {
($($key:ident $(: $value:expr)?),*$(,)?) => {{
use rocket::serde::ser::{Serialize, Serializer, SerializeMap};
use ::std::fmt::{Debug, Formatter};
#[allow(non_camel_case_types)]
struct ContextMacroCtxObject<$($key: Serialize),*> {
$($key: $key),*
}
#[allow(non_camel_case_types)]
impl<$($key: Serialize),*> Serialize for ContextMacroCtxObject<$($key),*> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,
{
let mut map = serializer.serialize_map(None)?;
$(map.serialize_entry(stringify!($key), &self.$key)?;)*
map.end()
}
}
#[allow(non_camel_case_types)]
impl<$($key: Debug + Serialize),*> Debug for ContextMacroCtxObject<$($key),*> {
fn fmt(&self, f: &mut Formatter<'_>) -> ::std::fmt::Result {
f.debug_struct("context!")
$(.field(stringify!($key), &self.$key))*
.finish()
}
}
ContextMacroCtxObject {
$($key $(: $value)?),*
}
}};
}