use super::App;
use axum::Router;
impl<S> App<S>
where
S: Clone + Send + Sync + 'static,
{
pub fn new() -> App<S> {
App {
router: Router::new(),
}
}
}
impl Default for App<()> {
fn default() -> Self {
App {
router: Router::new(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn empty_stateless_app_constructs() {
let _app = App::default();
}
#[test]
fn generic_new_infers_state_from_route() {
use axum::extract::State;
use axum::routing::get;
#[derive(Clone)]
struct S;
let _app: App<()> = App::new()
.route("/", get(|_state: State<S>| async { "ok" }))
.with_state(S);
}
}