1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-10-06 18:22:03 +00:00
actix-web/src/lib.rs

189 lines
4.6 KiB
Rust
Raw Normal View History

2018-02-27 20:49:11 +00:00
//! Actix web is a small, pragmatic, extremely fast, web framework for Rust.
2017-12-14 07:35:21 +00:00
//!
2018-01-09 18:08:06 +00:00
//! ```rust
2017-12-14 07:35:21 +00:00
//! use actix_web::*;
2018-01-09 18:08:06 +00:00
//! # use std::thread;
2017-12-14 07:35:21 +00:00
//!
//! fn index(req: HttpRequest) -> String {
//! format!("Hello {}!", &req.match_info()["name"])
//! }
//!
//! fn main() {
2018-01-09 18:08:06 +00:00
//! # thread::spawn(|| {
2017-12-14 07:35:21 +00:00
//! HttpServer::new(
//! || Application::new()
//! .resource("/{name}", |r| r.f(index)))
2018-01-09 18:08:06 +00:00
//! .bind("127.0.0.1:8080").unwrap()
//! .run();
//! # });
2017-12-14 07:35:21 +00:00
//! }
//! ```
//!
//! ## Documentation
//!
//! * [User Guide](http://actix.github.io/actix-web/guide/)
2018-01-12 02:49:30 +00:00
//! * [Chat on gitter](https://gitter.im/actix/actix)
2018-01-12 02:47:34 +00:00
//! * [GitHub repository](https://github.com/actix/actix-web)
//! * [Cargo package](https://crates.io/crates/actix-web)
//! * Supported Rust version: 1.21 or later
2017-12-14 07:35:21 +00:00
//!
//! ## Features
//!
//! * Supported *HTTP/1.x* and *HTTP/2.0* protocols
//! * Streaming and pipelining
//! * Keep-alive and slow requests handling
2018-02-26 22:33:56 +00:00
//! * `WebSockets` server/client
2017-12-14 07:35:21 +00:00
//! * Transparent content compression/decompression (br, gzip, deflate)
//! * Configurable request routing
2018-03-01 06:31:54 +00:00
//! * Graceful server shutdown
2017-12-14 07:35:21 +00:00
//! * Multipart streams
2018-03-01 06:31:54 +00:00
//! * SSL support with openssl or native-tls
//! * Middlewares (`Logger`, `Session`, `CORS`, `DefaultHeaders`)
2018-03-01 06:31:54 +00:00
//! * Built on top of [Actix actor framework](https://github.com/actix/actix).
2017-10-07 04:48:14 +00:00
2017-11-24 18:28:43 +00:00
#![cfg_attr(actix_nightly, feature(
specialization, // for impl ErrorResponse for std::error::Error
))]
#![cfg_attr(feature = "cargo-clippy", allow(
2018-02-26 21:58:23 +00:00
decimal_literal_representation,suspicious_arithmetic_impl,))]
2017-10-07 04:48:14 +00:00
#[macro_use]
extern crate log;
extern crate time;
2018-01-28 06:03:03 +00:00
extern crate base64;
2017-10-07 04:48:14 +00:00
extern crate bytes;
extern crate byteorder;
2017-10-08 04:48:00 +00:00
extern crate sha1;
2017-10-17 02:21:24 +00:00
extern crate regex;
2017-10-07 04:48:14 +00:00
#[macro_use]
extern crate bitflags;
#[macro_use]
2017-12-29 09:01:31 +00:00
extern crate failure;
#[macro_use]
2017-10-07 04:48:14 +00:00
extern crate futures;
extern crate tokio_io;
2017-10-29 13:05:31 +00:00
extern crate tokio_core;
2017-12-27 19:22:27 +00:00
extern crate mio;
extern crate net2;
extern crate cookie;
2017-10-07 04:48:14 +00:00
extern crate http;
extern crate httparse;
extern crate http_range;
2017-10-19 06:43:50 +00:00
extern crate mime;
2017-10-16 08:19:23 +00:00
extern crate mime_guess;
2018-03-06 08:43:25 +00:00
extern crate language_tags;
2018-01-28 06:03:03 +00:00
extern crate rand;
extern crate url;
2017-11-10 21:26:12 +00:00
extern crate libc;
2017-11-16 06:06:28 +00:00
extern crate serde;
extern crate serde_json;
2017-11-06 09:24:49 +00:00
extern crate flate2;
extern crate brotli2;
extern crate encoding;
extern crate percent_encoding;
extern crate smallvec;
extern crate num_cpus;
extern crate h2 as http2;
2018-01-28 06:03:03 +00:00
extern crate trust_dns_resolver;
2017-12-27 20:58:32 +00:00
#[macro_use] extern crate actix;
2017-10-07 04:48:14 +00:00
2017-12-04 02:51:52 +00:00
#[cfg(test)]
#[macro_use] extern crate serde_derive;
2017-11-16 06:06:28 +00:00
#[cfg(feature="tls")]
extern crate native_tls;
#[cfg(feature="tls")]
extern crate tokio_tls;
#[cfg(feature="openssl")]
extern crate openssl;
#[cfg(feature="openssl")]
extern crate tokio_openssl;
2017-10-07 04:48:14 +00:00
mod application;
2017-10-24 06:25:32 +00:00
mod body;
2017-10-07 04:48:14 +00:00
mod context;
mod handler;
2017-12-14 06:54:52 +00:00
mod helpers;
mod httpmessage;
mod httprequest;
2017-10-15 16:33:17 +00:00
mod httpresponse;
2017-12-06 01:09:15 +00:00
mod info;
2017-12-21 01:51:28 +00:00
mod json;
2017-12-05 00:09:22 +00:00
mod route;
2017-12-07 00:26:27 +00:00
mod router;
2017-10-07 04:48:14 +00:00
mod resource;
mod param;
mod payload;
2017-11-25 06:15:52 +00:00
mod pipeline;
2017-10-08 04:48:00 +00:00
pub mod client;
pub mod fs;
2017-10-10 06:07:32 +00:00
pub mod ws;
2017-11-16 06:06:28 +00:00
pub mod error;
pub mod header;
2017-10-07 04:48:14 +00:00
pub mod httpcodes;
2017-10-19 06:43:50 +00:00
pub mod multipart;
2017-12-27 03:59:41 +00:00
pub mod middleware;
2017-12-04 21:32:05 +00:00
pub mod pred;
pub mod test;
2018-01-12 02:35:05 +00:00
pub mod server;
2017-12-08 23:25:37 +00:00
pub use error::{Error, Result, ResponseError};
2017-11-10 21:42:32 +00:00
pub use body::{Body, Binary};
2018-01-12 02:35:05 +00:00
pub use json::Json;
2017-11-27 06:53:28 +00:00
pub use application::Application;
pub use httpmessage::HttpMessage;
2017-12-08 00:40:29 +00:00
pub use httprequest::HttpRequest;
2017-11-27 06:53:28 +00:00
pub use httpresponse::HttpResponse;
2017-12-21 04:30:54 +00:00
pub use handler::{Reply, Responder, NormalizePath, AsyncResponder};
2017-12-05 00:09:22 +00:00
pub use route::Route;
pub use resource::Resource;
2017-10-07 04:48:14 +00:00
pub use context::HttpContext;
2018-01-12 02:35:05 +00:00
pub use server::HttpServer;
2017-10-14 17:40:58 +00:00
// re-exports
pub use http::{Method, StatusCode, Version};
2018-01-30 07:01:20 +00:00
#[cfg(feature="openssl")]
pub(crate) const HAS_OPENSSL: bool = true;
#[cfg(not(feature="openssl"))]
pub(crate) const HAS_OPENSSL: bool = false;
2018-03-07 01:34:46 +00:00
#[cfg(feature="tls")]
pub(crate) const HAS_TLS: bool = true;
#[cfg(not(feature="tls"))]
pub(crate) const HAS_TLS: bool = false;
2018-01-30 07:01:20 +00:00
2018-03-06 19:02:03 +00:00
#[doc(hidden)]
#[deprecated(since="0.4.4", note="please use `actix::header` module")]
2017-12-08 00:40:29 +00:00
pub mod headers {
//! Headers implementation
2017-12-14 05:38:47 +00:00
pub use httpresponse::ConnectionType;
2018-01-12 02:41:33 +00:00
pub use cookie::{Cookie, CookieBuilder};
2017-12-08 00:40:29 +00:00
pub use http_range::HttpRange;
pub use header::ContentEncoding;
2017-12-08 00:40:29 +00:00
}
2017-12-07 01:06:40 +00:00
pub mod dev {
//! The `actix-web` prelude for library developers
//!
//! The purpose of this module is to alleviate imports of many common actix traits
//! by adding a glob import to the top of actix heavy modules:
//!
//! ```
//! # #![allow(unused_imports)]
//! use actix_web::dev::*;
//! ```
2017-12-14 06:36:28 +00:00
pub use body::BodyStream;
2018-02-28 19:10:54 +00:00
pub use context::Drain;
2017-12-07 01:06:40 +00:00
pub use info::ConnectionInfo;
pub use handler::Handler;
2017-12-21 04:30:54 +00:00
pub use json::JsonBody;
pub use router::{Router, Pattern};
pub use param::{FromParam, Params};
pub use httpmessage::{UrlEncoded, MessageBody};
2017-12-07 01:06:40 +00:00
pub use httpresponse::HttpResponseBuilder;
}