1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-02-21 18:12:47 +01:00
actix-extras/src/lib.rs

130 lines
3.5 KiB
Rust
Raw Normal View History

//! Actix web is a small, pragmatic, and extremely fast web framework
//! for Rust.
2017-12-13 23:35:21 -08:00
//!
2018-10-04 21:14:18 -07:00
//! ```rust,ignore
2018-06-02 16:03:23 -07:00
//! use actix_web::{server, App, Path, Responder};
2018-01-09 10:08:06 -08:00
//! # use std::thread;
2017-12-13 23:35:21 -08:00
//!
2018-06-02 16:03:23 -07:00
//! fn index(info: Path<(String, u32)>) -> impl Responder {
2018-06-01 09:36:16 -07:00
//! format!("Hello {}! id:{}", info.0, info.1)
2017-12-13 23:35:21 -08:00
//! }
//!
//! fn main() {
2018-06-01 10:27:23 -07:00
//! # thread::spawn(|| {
2018-06-01 09:36:16 -07:00
//! server::new(|| {
//! App::new().resource("/{name}/{id}/index.html", |r| r.with(index))
//! }).bind("127.0.0.1:8080")
//! .unwrap()
2018-01-09 10:08:06 -08:00
//! .run();
2018-06-01 10:27:23 -07:00
//! # });
2017-12-13 23:35:21 -08:00
//! }
//! ```
//!
//! ## Documentation & community resources
//!
//! Besides the API documentation (which you are currently looking
//! at!), several other resources are available:
2017-12-13 23:35:21 -08:00
//!
2018-05-23 11:20:12 -07:00
//! * [User Guide](https://actix.rs/docs/)
2018-01-11 18:49:30 -08:00
//! * [Chat on gitter](https://gitter.im/actix/actix)
2018-01-11 18:47:34 -08:00
//! * [GitHub repository](https://github.com/actix/actix-web)
//! * [Cargo package](https://crates.io/crates/actix-web)
//!
//! 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 11:04:59 -07:00
//! * [Request](struct.Request.html) and
//! [Response](struct.Response.html): These structs
//! represent HTTP requests and responses and expose various methods
2018-05-06 19:07:30 +03:00
//! for inspecting, creating and otherwise utilizing them.
2017-12-13 23:35:21 -08:00
//!
//! ## Features
//!
2018-10-08 10:14:29 -07:00
//! * Supported *HTTP/1.x* protocol
2017-12-13 23:35:21 -08:00
//! * Streaming and pipelining
//! * Keep-alive and slow requests handling
2018-02-26 14:33:56 -08:00
//! * `WebSockets` server/client
2018-05-24 21:09:20 -07:00
//! * Supported Rust version: 1.26 or later
2018-05-15 10:20:32 -07:00
//!
//! ## Package feature
//!
//! * `session` - enables session support, includes `ring` crate as
//! dependency
//!
pub mod body;
pub mod client;
2018-10-04 20:02:10 -07:00
mod config;
2018-06-17 03:22:08 +06:00
mod extensions;
2018-03-30 17:31:18 -07:00
mod header;
2018-12-06 14:32:52 -08:00
mod helpers;
2018-04-29 21:05:10 -07:00
mod httpcodes;
mod httpmessage;
2017-12-20 17:51:28 -08:00
mod json;
2018-11-16 19:28:07 -08:00
mod message;
mod payload;
2018-10-04 20:02:10 -07:00
mod request;
2018-10-05 11:04:59 -07:00
mod response;
2018-10-22 09:59:20 -07:00
mod service;
2017-10-07 21:48:00 -07:00
2017-11-15 20:06:28 -10:00
pub mod error;
2018-10-04 20:02:10 -07:00
pub mod h1;
2018-10-04 21:14:18 -07:00
pub mod test;
2018-10-05 10:19:15 -07:00
pub mod ws;
2018-10-04 20:02:10 -07:00
2018-12-06 14:32:52 -08:00
pub use self::body::{Body, MessageBody};
2018-10-05 08:00:36 -07:00
pub use self::config::{KeepAlive, ServiceConfig, ServiceConfigBuilder};
2018-12-06 14:32:52 -08:00
pub use self::error::{Error, ResponseError, Result};
pub use self::extensions::Extensions;
pub use self::httpmessage::HttpMessage;
pub use self::request::Request;
pub use self::response::Response;
pub use self::service::{SendError, SendResponse};
2018-05-09 05:48:06 -07:00
2017-12-06 17:06:40 -08:00
pub mod dev {
2018-04-13 16:02:01 -07: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-04 21:14:18 -07:00
//! use actix_http::dev::*;
2018-04-13 16:02:01 -07:00
//! ```
2017-12-06 17:06:40 -08:00
2018-12-06 14:32:52 -08:00
pub use crate::httpmessage::{MessageBody, Readlines, UrlEncoded};
pub use crate::json::JsonBody;
pub use crate::payload::{Payload, PayloadBuffer};
pub use crate::response::ResponseBuilder;
2017-12-06 17:06:40 -08:00
}
2018-03-30 17:31:18 -07:00
pub mod http {
//! Various HTTP related types
2018-03-30 17:31:18 -07:00
// re-exports
2018-12-06 14:32:52 -08:00
pub use http::header::{HeaderName, HeaderValue};
pub use http::{Method, StatusCode, Version};
2018-03-30 17:31:18 -07:00
#[doc(hidden)]
2018-12-06 14:32:52 -08:00
pub use http::{uri, Error, HeaderMap, HttpTryFrom, Uri};
2018-03-30 17:31:18 -07:00
2018-11-25 20:14:42 -10:00
#[doc(hidden)]
2018-12-06 14:32:52 -08:00
pub use http::uri::PathAndQuery;
2018-11-25 20:14:42 -10:00
2018-03-30 17:31:18 -07:00
pub use cookie::{Cookie, CookieBuilder};
/// Various http headers
2018-03-30 17:31:18 -07:00
pub mod header {
2018-12-06 14:32:52 -08:00
pub use crate::header::*;
2018-03-30 17:31:18 -07:00
}
2018-12-06 14:32:52 -08:00
pub use crate::header::ContentEncoding;
pub use crate::message::ConnectionType;
2018-11-18 21:48:20 -08:00
}