mod app;
mod app_service;
mod config;
pub mod error;
mod error_default;
mod extract;
pub mod guard;
mod handler;
mod httprequest;
mod info;
pub mod middleware;
mod request;
mod resource;
mod responder;
mod response;
mod rmap;
mod route;
mod scope;
mod server;
mod service;
pub mod test;
pub mod types;
mod util;
pub mod ws;
pub use ntex_macros::web_connect as connect;
pub use ntex_macros::web_delete as delete;
pub use ntex_macros::web_get as get;
pub use ntex_macros::web_head as head;
pub use ntex_macros::web_options as options;
pub use ntex_macros::web_patch as patch;
pub use ntex_macros::web_post as post;
pub use ntex_macros::web_put as put;
pub use ntex_macros::web_trace as trace;
pub use crate::http::Response as HttpResponse;
pub use crate::http::ResponseBuilder as HttpResponseBuilder;
pub use either::Either;
pub use self::app::App;
pub use self::config::ServiceConfig;
pub use self::error::{
DefaultError, Error, ErrorContainer, ErrorRenderer, WebResponseError,
};
pub use self::extract::FromRequest;
pub use self::handler::Handler;
pub use self::httprequest::HttpRequest;
pub use self::resource::Resource;
pub use self::responder::Responder;
pub use self::route::Route;
pub use self::scope::Scope;
pub use self::server::HttpServer;
pub use self::util::*;
pub mod dev {
use super::Handler;
pub use crate::web::config::AppConfig;
pub use crate::web::info::ConnectionInfo;
pub use crate::web::request::WebRequest;
pub use crate::web::response::WebResponse;
pub use crate::web::rmap::ResourceMap;
pub use crate::web::route::IntoRoutes;
pub use crate::web::service::{
WebServiceAdapter, WebServiceConfig, WebServiceFactory,
};
pub(crate) fn insert_slesh(mut patterns: Vec<String>) -> Vec<String> {
for path in &mut patterns {
if !path.is_empty() && !path.starts_with('/') {
path.insert(0, '/');
};
}
patterns
}
#[doc(hidden)]
#[inline(always)]
pub fn __assert_extractor<Err, T>()
where
T: super::FromRequest<Err>,
Err: super::ErrorRenderer,
<T as super::FromRequest<Err>>::Error: Into<Err::Container>,
{
}
#[doc(hidden)]
#[inline(always)]
pub fn __assert_handler<Err, Fun, Fut>(
f: Fun,
) -> impl Handler<(), Err, Future = Fut, Output = Fut::Output>
where
Err: super::ErrorRenderer,
Fun: Fn() -> Fut + Clone + 'static,
Fut: std::future::Future + 'static,
Fut::Output: super::Responder<Err>,
{
f
}
macro_rules! assert_handler ({ $name:ident, $($T:ident),+} => {
#[doc(hidden)]
#[inline(always)]
pub fn $name<Err, Fun, Fut, $($T,)+>(
f: Fun,
) -> impl Handler<($($T,)+), Err, Future = Fut, Output = Fut::Output>
where
Err: $crate::web::ErrorRenderer,
Fun: Fn($($T,)+) -> Fut + Clone + 'static,
Fut: std::future::Future + 'static,
Fut::Output: $crate::web::Responder<Err>,
$($T: $crate::web::FromRequest<Err>),+,
{
f
}
});
assert_handler!(__assert_handler1, A);
assert_handler!(__assert_handler2, A, B);
assert_handler!(__assert_handler3, A, B, C);
assert_handler!(__assert_handler4, A, B, C, D);
assert_handler!(__assert_handler5, A, B, C, D, E);
assert_handler!(__assert_handler6, A, B, C, D, E, F);
assert_handler!(__assert_handler7, A, B, C, D, E, F, G);
assert_handler!(__assert_handler8, A, B, C, D, E, F, G, H);
assert_handler!(__assert_handler9, A, B, C, D, E, F, G, H, I);
assert_handler!(__assert_handler10, A, B, C, D, E, F, G, H, I, J);
}