pub mod schema {
pub use vespera_core::schema::*;
}
pub mod route {
pub use vespera_core::route::*;
}
pub mod openapi {
pub use vespera_core::openapi::*;
}
pub use vespera_core::openapi::OpenApi;
pub use vespera_macro::{Multipart, Schema, cron, export_app, route, schema, schema_type, vespera};
pub trait Schema {}
pub use serde_json;
pub use chrono;
pub mod multipart;
pub use tempfile;
#[cfg(feature = "cron")]
pub use tokio_cron_scheduler;
#[cfg(feature = "cron")]
pub use tokio;
pub mod axum {
pub use axum::*;
}
pub mod axum_extra {
pub use axum_extra::*;
}
pub struct VesperaRouter<S>
where
S: Clone + Send + Sync + 'static,
{
base: axum::Router<S>,
merge_fns: Vec<fn() -> axum::Router<()>>,
layers: Vec<Box<dyn FnOnce(axum::Router) -> axum::Router + Send + Sync>>,
}
impl<S> VesperaRouter<S>
where
S: Clone + Send + Sync + 'static,
{
#[must_use]
pub fn new(base: axum::Router<S>, merge_fns: Vec<fn() -> axum::Router<()>>) -> Self {
Self {
base,
merge_fns,
layers: Vec::new(),
}
}
pub fn with_state(self, state: S) -> axum::Router<()> {
let mut router: axum::Router<()> = self.base.with_state(state);
for merge_fn in self.merge_fns {
router = router.merge(merge_fn());
}
for apply in self.layers {
router = apply(router);
}
router
}
#[must_use]
pub fn layer<L>(mut self, layer: L) -> Self
where
L: tower_layer::Layer<axum::routing::Route> + Clone + Send + Sync + 'static,
L::Service: tower_service::Service<axum::extract::Request> + Clone + Send + Sync + 'static,
<L::Service as tower_service::Service<axum::extract::Request>>::Response:
axum::response::IntoResponse + 'static,
<L::Service as tower_service::Service<axum::extract::Request>>::Error:
Into<std::convert::Infallible> + 'static,
<L::Service as tower_service::Service<axum::extract::Request>>::Future: Send + 'static,
{
self.layers
.push(Box::new(move |router: axum::Router| router.layer(layer)));
self
}
}
pub use tower_layer;
pub use tower_service;
#[cfg(feature = "validation")]
#[doc(hidden)]
pub mod __validation;
#[cfg(feature = "validation")]
mod validated;
#[cfg(feature = "validation")]
pub use validated::{
ValidatePayload, ValidatePayloadWith, Validated, ValidatedWith, ValidationContext,
};
#[cfg(feature = "inprocess")]
pub use vespera_inprocess as inprocess;
pub mod serve;
pub use serve::Serve;
#[cfg(feature = "jni")]
pub use vespera_jni as jni;
#[cfg(feature = "jni")]
#[macro_export]
macro_rules! jni_app {
($factory:expr) => {
$crate::jni::jni_app!($factory);
};
}
#[cfg(feature = "jni")]
#[macro_export]
macro_rules! jni_apps {
( $( $name:literal => $factory:expr ),+ $(,)? ) => {
$crate::jni::jni_apps! {
$( $name => $factory ),+
}
};
}