1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
#![doc = include_str!("../README.md")]
#![warn(missing_docs)]
/// Current version of afire
#[doc(hidden)]
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
/// Contains all the constants used in afire.
/// These may be in the future moved into the [`Server`] struct.
mod consts {
/// The initial buffer allocation for the request.
pub const BUFF_SIZE: usize = 256;
/// Max chunk size for chunked transfer encoding.
pub const CHUNK_SIZE: usize = 16 * 1024;
}
// Export Internal Functions
pub mod internal;
// Import Internal Functions
mod thread_pool;
use http::*;
use internal::{encoding, handle, path};
#[macro_use]
pub mod trace;
pub mod error;
mod http;
pub mod middleware;
mod request;
mod response;
mod route;
mod server;
pub use self::{
content_type::Content,
cookie::{Cookie, SetCookie},
error::Error,
header::{Header, HeaderType},
http::{cookie, header, multipart, server_sent_events},
method::Method,
middleware::Middleware,
query::Query,
request::Request,
response::Response,
route::Route,
server::Server,
status::Status,
};
/// The Prelude is a collection of very commonly used *things* in afire.
/// Unless you are using middleware, extensions or internal lower level stuff this should be all you need!
pub mod prelude {
pub use crate::{
error::{self, Error},
middleware::{MiddleResult, Middleware},
server_sent_events::ServerSentEventsExt,
Content, Cookie, Header, HeaderType, Method, Query, Request, Response, Server, SetCookie,
Status,
};
}
// Extra Features
#[cfg(feature = "extensions")]
mod extensions;
#[cfg(feature = "extensions")]
pub mod extension {
//! Useful extensions to the base afire.
//! Includes helpful middleware like Serve Static, Rate Limit and Logger.
//!
//! ## All Feature
//! | Name | Description |
//! | --------------- | ----------------------------------------------------- |
//! | [`Date`] | Add the Date header to responses. Required by HTTP. |
//! | [`Head`] | Add support for HTTP `HEAD` requests. |
//! | [`Logger`] | Log incoming requests to the console / file. |
//! | [`RateLimiter`] | Limit how many requests can be handled from a source. |
//! | [`RealIp`] | Get the real IP of a client through a reverse proxy |
//! | [`RequestId`] | Add a Request-Id header to all requests. |
//! | [`ServeStatic`] | Serve static files from a dir. |
//! | [`Trace`] | Add support for the HTTP `TRACE` method. |
pub use crate::extensions::{
date::{self, Date},
head::Head,
logger::{self, Logger},
ratelimit::RateLimiter,
real_ip::RealIp,
request_id::RequestId,
serve_static::{self, ServeStatic},
trace::Trace,
};
}