#![forbid(unsafe_code)]
pub mod constants;
mod app;
mod body;
mod cache;
mod env;
mod error;
mod extract;
mod hooks;
mod lifespan;
mod logging;
pub mod middleware;
mod multipart;
mod openapi;
mod realtime;
#[cfg(feature = "redis")]
mod redis_handle;
mod resources;
mod response;
mod router;
pub mod security;
mod server;
#[cfg(feature = "tls")]
pub mod tls;
mod service;
mod settings;
mod sse;
mod state;
pub mod testing;
mod throttle;
mod ws;
pub use app::{App, AppInner, TestApp};
pub use lifespan::{Lifespan, LifespanContext, ReadyContext};
pub use logging::{
ErrorLogDetail, FileLogConfig, LogEvent, LogFormat, LogSpan, Logger, LoggerConfig, Rotation,
TelemetryConfig,
};
pub use middleware::{DuplicatePolicy, Middleware, Next, Request};
#[doc(hidden)]
pub use multipart::{
__parse_multipart, __validate_file_bytes, __validate_upload, FileRule, MultipartForm,
};
pub use multipart::{FileBytes, Form, FromMultipart, Multipart, UploadConfig, UploadFile};
pub use body::{box_body, BoxError, ReqBody, RespBody};
#[cfg(feature = "redis")]
pub use cache::RedisStore;
pub use cache::{Cache, CacheStore, MemoryStore};
pub use ipnet::IpNet;
pub use mime;
#[cfg(feature = "redis")]
pub use redis_handle::Redis;
pub use resources::Resources;
pub use server::{Http1Config, Http2Config, TorkService};
#[doc(hidden)]
pub use throttle::check_request as __throttle_check;
#[cfg(feature = "redis")]
pub use throttle::RedisThrottleStore;
pub use throttle::{
ByIp, MemoryThrottleStore, Throttle, ThrottleKey, ThrottlePolicy, ThrottleStore, Throttler,
};
#[cfg(feature = "redis")]
pub use ::redis;
pub use error::{Error, ErrorDetail, ErrorKind, Result};
pub use extract::{
__extract_path_param, BearerToken, FromPathParam, FromRequest, LastEventId, PathParams,
RequestContext, SseResume, Valid,
};
pub use hooks::{
ErrorContext, ErrorEvent, PanicEvent, RequestEvent, ResponseEvent, ValidationErrorEvent,
};
pub use openapi::{AsyncApiProvider, OpenApiProvider};
pub use realtime::{Hub, Room};
pub use response::{
__finish, __finish_into, bytes_response, json_response, IntoResponse, Json, Response,
};
pub use router::matcher::{Match, Matcher};
pub use router::{BoxFuture, HandlerFn, RequestBodyKind, Route, RouteMeta, Router, SchemaThunk};
pub use settings::{SecretString, SettingsLoader};
pub use security::constant_time_eq;
#[cfg(feature = "tls")]
pub use tls::TlsConfig;
pub use tokio::sync::broadcast::Receiver as WsReceiver;
#[doc(hidden)]
pub use sse::__sse_into_response;
pub use sse::{Sse, SseEvent};
pub use state::{AppStateRef, State, StateMap};
#[doc(hidden)]
pub use testing::__take_override;
pub use ws::{
__ws_handshake, WebSocket, WebSocketConfig, WebSocketConn, WsClose, WsCloseCode, WsConnectInfo,
WsDisconnectInfo, WsError, WsMessage,
};
pub use http::{header, HeaderMap, HeaderName, HeaderValue, Method, StatusCode};
#[doc(hidden)]
pub mod __rt {
pub fn block_on<F: std::future::Future>(future: F) -> F::Output {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.expect("failed to build the Tokio runtime")
.block_on(future)
}
pub fn spawn<F>(future: F)
where
F: std::future::Future<Output = ()> + Send + 'static,
{
tokio::spawn(future);
}
}
#[cfg(test)]
mod tests {
#[test]
fn runtime_block_on_executes_future() {
let value = crate::__rt::block_on(async { 7usize });
assert_eq!(value, 7);
}
}