mirror of
https://github.com/actix/actix-web.git
synced 2024-12-22 08:07:18 +00:00
3033f187d2
* Enforce safety of `downcast_ref` at compile time. The safety of `downcast_ref` requires that `__private_get_type_id__` not be overriden by callers, since the returned `TypeId` is used to check if the cast is safe. However, all trait methods in Rust are public, so users can override `__private_get_type_id__` despite it being `#[doc(hidden)]`. This commit makes `__private_get_type_id__` return a type with a private constructor, ensuring that the only possible implementation is the default implementation. A more detailed explanation is provided in the comments added to the file. Note that the standard library was affected by this type of issue with the `Error::type_id` function: see https://blog.rust-lang.org/2019/05/14/Rust-1.34.2.html#whats-in-1.34.2-stable Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com> |
||
---|---|---|
.. | ||
examples | ||
src | ||
tests | ||
.appveyor.yml | ||
Cargo.toml | ||
CHANGES.md | ||
CODE_OF_CONDUCT.md | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md | ||
rustfmt.toml |
Actix http
Actix http
Documentation & community resources
- User Guide
- API Documentation
- Chat on gitter
- Cargo package: actix-http
- Minimum supported Rust version: 1.31 or later
Example
// see examples/framed_hello.rs for complete list of used crates.
extern crate actix_http;
use actix_http::{h1, Response, ServiceConfig};
fn main() {
Server::new().bind("framed_hello", "127.0.0.1:8080", || {
IntoFramed::new(|| h1::Codec::new(ServiceConfig::default())) // <- create h1 codec
.and_then(TakeItem::new().map_err(|_| ())) // <- read one request
.and_then(|(_req, _framed): (_, Framed<_, _>)| { // <- send response and close conn
SendResponse::send(_framed, Response::Ok().body("Hello world!"))
.map_err(|_| ())
.map(|_| ())
})
}).unwrap().run();
}
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Code of Conduct
Contribution to the actix-http crate is organized under the terms of the Contributor Covenant, the maintainer of actix-http, @fafhrd91, promises to intervene to uphold that code of conduct.