2018-04-07 17:10:36 +02:00
|
|
|
//! Actix web is a small, pragmatic, and extremely fast web framework
|
|
|
|
//! for Rust.
|
2017-12-14 08:35:21 +01:00
|
|
|
//!
|
2018-10-05 06:14:18 +02:00
|
|
|
//! ```rust,ignore
|
2018-06-03 01:03:23 +02:00
|
|
|
//! use actix_web::{server, App, Path, Responder};
|
2018-01-09 19:08:06 +01:00
|
|
|
//! # use std::thread;
|
2017-12-14 08:35:21 +01:00
|
|
|
//!
|
2018-06-03 01:03:23 +02:00
|
|
|
//! fn index(info: Path<(String, u32)>) -> impl Responder {
|
2018-06-01 18:36:16 +02:00
|
|
|
//! format!("Hello {}! id:{}", info.0, info.1)
|
2017-12-14 08:35:21 +01:00
|
|
|
//! }
|
|
|
|
//!
|
|
|
|
//! fn main() {
|
2018-06-01 19:27:23 +02:00
|
|
|
//! # thread::spawn(|| {
|
2018-06-01 18:36:16 +02:00
|
|
|
//! server::new(|| {
|
|
|
|
//! App::new().resource("/{name}/{id}/index.html", |r| r.with(index))
|
|
|
|
//! }).bind("127.0.0.1:8080")
|
|
|
|
//! .unwrap()
|
2018-01-09 19:08:06 +01:00
|
|
|
//! .run();
|
2018-06-01 19:27:23 +02:00
|
|
|
//! # });
|
2017-12-14 08:35:21 +01:00
|
|
|
//! }
|
|
|
|
//! ```
|
|
|
|
//!
|
2018-04-07 17:27:53 +02:00
|
|
|
//! ## Documentation & community resources
|
|
|
|
//!
|
|
|
|
//! Besides the API documentation (which you are currently looking
|
|
|
|
//! at!), several other resources are available:
|
2017-12-14 08:35:21 +01:00
|
|
|
//!
|
2018-05-23 20:20:12 +02:00
|
|
|
//! * [User Guide](https://actix.rs/docs/)
|
2018-01-12 03:49:30 +01:00
|
|
|
//! * [Chat on gitter](https://gitter.im/actix/actix)
|
2018-01-12 03:47:34 +01:00
|
|
|
//! * [GitHub repository](https://github.com/actix/actix-web)
|
2018-02-19 07:23:17 +01:00
|
|
|
//! * [Cargo package](https://crates.io/crates/actix-web)
|
2018-04-07 17:27:53 +02:00
|
|
|
//!
|
|
|
|
//! To get started navigating the API documentation you may want to
|
|
|
|
//! consider looking at the following pages:
|
|
|
|
//!
|
|
|
|
//! * [App](struct.App.html): This struct represents an actix-web
|
|
|
|
//! application and is used to configure routes and other common
|
|
|
|
//! settings.
|
|
|
|
//!
|
|
|
|
//! * [HttpServer](server/struct.HttpServer.html): This struct
|
|
|
|
//! represents an HTTP server instance and is used to instantiate and
|
|
|
|
//! configure servers.
|
|
|
|
//!
|
2018-10-05 20:04:59 +02:00
|
|
|
//! * [Request](struct.Request.html) and
|
|
|
|
//! [Response](struct.Response.html): These structs
|
2018-04-07 17:27:53 +02:00
|
|
|
//! represent HTTP requests and responses and expose various methods
|
2018-05-06 18:07:30 +02:00
|
|
|
//! for inspecting, creating and otherwise utilizing them.
|
2017-12-14 08:35:21 +01:00
|
|
|
//!
|
|
|
|
//! ## Features
|
|
|
|
//!
|
2018-10-08 19:14:29 +02:00
|
|
|
//! * Supported *HTTP/1.x* protocol
|
2017-12-14 08:35:21 +01:00
|
|
|
//! * Streaming and pipelining
|
|
|
|
//! * Keep-alive and slow requests handling
|
2018-02-26 23:33:56 +01:00
|
|
|
//! * `WebSockets` server/client
|
2018-05-25 06:09:20 +02:00
|
|
|
//! * Supported Rust version: 1.26 or later
|
2018-05-15 19:20:32 +02:00
|
|
|
//!
|
|
|
|
//! ## Package feature
|
|
|
|
//!
|
|
|
|
//! * `session` - enables session support, includes `ring` crate as
|
|
|
|
//! dependency
|
|
|
|
//!
|
2018-10-05 06:14:18 +02:00
|
|
|
// #![warn(missing_docs)]
|
2018-10-05 08:39:11 +02:00
|
|
|
#![allow(dead_code)]
|
2017-11-24 19:03:13 +01:00
|
|
|
|
2018-10-05 02:00:27 +02:00
|
|
|
extern crate actix;
|
2018-10-05 06:14:18 +02:00
|
|
|
extern crate actix_net;
|
2017-10-07 06:48:14 +02:00
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
2018-01-28 07:03:03 +01:00
|
|
|
extern crate base64;
|
2018-02-10 02:20:28 +01:00
|
|
|
extern crate byteorder;
|
2018-04-14 01:02:01 +02:00
|
|
|
extern crate bytes;
|
|
|
|
extern crate sha1;
|
|
|
|
extern crate time;
|
2017-10-07 06:48:14 +02:00
|
|
|
#[macro_use]
|
2017-12-08 06:52:46 +01:00
|
|
|
extern crate bitflags;
|
|
|
|
#[macro_use]
|
2017-12-29 10:01:31 +01:00
|
|
|
extern crate failure;
|
|
|
|
#[macro_use]
|
2018-04-02 02:37:22 +02:00
|
|
|
extern crate lazy_static;
|
|
|
|
#[macro_use]
|
2017-10-07 06:48:14 +02:00
|
|
|
extern crate futures;
|
2017-10-15 07:52:38 +02:00
|
|
|
extern crate cookie;
|
2018-10-05 06:14:18 +02:00
|
|
|
extern crate encoding;
|
2018-03-31 02:31:18 +02:00
|
|
|
extern crate http as modhttp;
|
2018-04-14 01:02:01 +02:00
|
|
|
extern crate httparse;
|
2018-11-12 08:12:54 +01:00
|
|
|
extern crate indexmap;
|
2017-10-19 08:43:50 +02:00
|
|
|
extern crate mime;
|
2018-04-14 01:02:01 +02:00
|
|
|
extern crate net2;
|
2018-10-23 03:18:05 +02:00
|
|
|
extern crate percent_encoding;
|
2018-01-28 07:03:03 +01:00
|
|
|
extern crate rand;
|
2018-10-05 06:14:18 +02:00
|
|
|
extern crate serde;
|
2018-10-05 17:00:36 +02:00
|
|
|
extern crate serde_json;
|
2018-10-05 06:14:18 +02:00
|
|
|
extern crate serde_urlencoded;
|
2018-11-12 08:12:54 +01:00
|
|
|
extern crate slab;
|
2018-10-05 16:02:09 +02:00
|
|
|
extern crate tokio;
|
2018-10-05 01:22:00 +02:00
|
|
|
extern crate tokio_codec;
|
2018-09-08 05:46:43 +02:00
|
|
|
extern crate tokio_current_thread;
|
2018-04-14 01:02:01 +02:00
|
|
|
extern crate tokio_io;
|
2018-05-25 06:03:16 +02:00
|
|
|
extern crate tokio_tcp;
|
|
|
|
extern crate tokio_timer;
|
2018-11-12 08:12:54 +01:00
|
|
|
extern crate trust_dns_proto;
|
|
|
|
extern crate trust_dns_resolver;
|
2018-10-23 03:18:05 +02:00
|
|
|
extern crate url as urlcrate;
|
2017-10-07 06:48:14 +02:00
|
|
|
|
2017-12-04 03:51:52 +01:00
|
|
|
#[cfg(test)]
|
2018-04-14 01:02:01 +02:00
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_derive;
|
2017-11-16 07:06:28 +01:00
|
|
|
|
2018-11-12 08:12:54 +01:00
|
|
|
#[cfg(feature = "ssl")]
|
|
|
|
extern crate openssl;
|
|
|
|
|
2018-11-19 02:52:56 +01:00
|
|
|
extern crate backtrace;
|
|
|
|
|
2018-11-18 22:48:42 +01:00
|
|
|
pub mod body;
|
2018-10-23 03:18:05 +02:00
|
|
|
pub mod client;
|
2018-10-05 05:02:10 +02:00
|
|
|
mod config;
|
2018-06-16 23:22:08 +02:00
|
|
|
mod extensions;
|
2018-03-31 02:31:18 +02:00
|
|
|
mod header;
|
2018-04-30 06:05:10 +02:00
|
|
|
mod httpcodes;
|
2018-02-28 00:03:28 +01:00
|
|
|
mod httpmessage;
|
2017-12-21 02:51:28 +01:00
|
|
|
mod json;
|
2018-11-17 04:28:07 +01:00
|
|
|
mod message;
|
2018-02-27 00:26:27 +01:00
|
|
|
mod payload;
|
2018-10-05 05:02:10 +02:00
|
|
|
mod request;
|
2018-10-05 20:04:59 +02:00
|
|
|
mod response;
|
2018-10-22 18:59:20 +02:00
|
|
|
mod service;
|
2018-10-12 05:15:10 +02:00
|
|
|
pub mod uri;
|
2017-10-08 06:48:00 +02:00
|
|
|
|
2017-11-16 07:06:28 +01:00
|
|
|
pub mod error;
|
2018-10-05 05:02:10 +02:00
|
|
|
pub mod h1;
|
|
|
|
pub(crate) mod helpers;
|
2018-10-05 06:14:18 +02:00
|
|
|
pub mod test;
|
2018-10-05 19:19:15 +02:00
|
|
|
pub mod ws;
|
2018-11-18 22:48:42 +01:00
|
|
|
pub use body::{Body, MessageBody};
|
2018-04-14 01:02:01 +02:00
|
|
|
pub use error::{Error, ResponseError, Result};
|
2018-06-16 23:22:08 +02:00
|
|
|
pub use extensions::Extensions;
|
2018-04-02 23:55:42 +02:00
|
|
|
pub use httpmessage::HttpMessage;
|
2018-10-05 05:02:10 +02:00
|
|
|
pub use request::Request;
|
2018-10-05 20:04:59 +02:00
|
|
|
pub use response::Response;
|
2018-10-22 18:59:20 +02:00
|
|
|
pub use service::{SendError, SendResponse};
|
2018-10-05 05:02:10 +02:00
|
|
|
|
2018-10-05 17:00:36 +02:00
|
|
|
pub use self::config::{KeepAlive, ServiceConfig, ServiceConfigBuilder};
|
2018-05-09 14:48:06 +02:00
|
|
|
|
2017-12-07 02:06:40 +01:00
|
|
|
pub mod dev {
|
2018-04-14 01:02:01 +02:00
|
|
|
//! 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)]
|
2018-10-05 06:14:18 +02:00
|
|
|
//! use actix_http::dev::*;
|
2018-04-14 01:02:01 +02:00
|
|
|
//! ```
|
2017-12-07 02:06:40 +01:00
|
|
|
|
2018-08-16 15:11:15 +02:00
|
|
|
pub use httpmessage::{MessageBody, Readlines, UrlEncoded};
|
2018-10-05 02:00:27 +02:00
|
|
|
pub use json::JsonBody;
|
2018-07-18 06:01:28 +02:00
|
|
|
pub use payload::{Payload, PayloadBuffer};
|
2018-10-05 20:04:59 +02:00
|
|
|
pub use response::ResponseBuilder;
|
2017-12-07 02:06:40 +01:00
|
|
|
}
|
2018-03-31 02:31:18 +02:00
|
|
|
|
|
|
|
pub mod http {
|
2018-04-07 17:10:36 +02:00
|
|
|
//! Various HTTP related types
|
2018-03-31 02:31:18 +02:00
|
|
|
|
|
|
|
// re-exports
|
2018-10-12 05:15:10 +02:00
|
|
|
pub use modhttp::header::{HeaderName, HeaderValue};
|
2018-03-31 02:31:18 +02:00
|
|
|
pub use modhttp::{Method, StatusCode, Version};
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
2018-10-12 05:15:10 +02:00
|
|
|
pub use modhttp::{uri, Error, HeaderMap, HttpTryFrom, Uri};
|
2018-03-31 02:31:18 +02:00
|
|
|
|
|
|
|
pub use cookie::{Cookie, CookieBuilder};
|
|
|
|
|
2018-06-02 15:51:58 +02:00
|
|
|
/// Various http headers
|
2018-03-31 02:31:18 +02:00
|
|
|
pub mod header {
|
2018-04-14 01:02:01 +02:00
|
|
|
pub use header::*;
|
2018-03-31 02:31:18 +02:00
|
|
|
}
|
|
|
|
pub use header::ContentEncoding;
|
|
|
|
}
|