Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Dowwie authored Jun 24, 2019
2 parents fa7e0fe + b948f74 commit 93855b8
Show file tree
Hide file tree
Showing 23 changed files with 178 additions and 103 deletions.
25 changes: 20 additions & 5 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
# Changes

## [1.0.1] - 2019-06-xx
## [1.0.3] - unreleased

### Changed

* Use `encoding_rs` crate instead of unmaintained `encoding` crate

## [1.0.2] - 2019-06-17

### Changed

* Move cors middleware to `actix-cors` crate.

* Move identity middleware to `actix-identity` crate.


## [1.0.1] - 2019-06-17

### Add

* Add support for PathConfig #903

* Add `middleware::identity::RequestIdentity` trait to `get_identity` from `HttpMessage`.

### Changes
### Changed

* Move cors middleware to `actix-cors` crate.

Expand Down Expand Up @@ -38,7 +53,7 @@

* Add macros for head, options, trace, connect and patch http methods

### Changes
### Changed

* Drop an unnecessary `Option<_>` indirection around `ServerBuilder` from `HttpServer`. #863

Expand All @@ -56,7 +71,7 @@
* Add `Query<T>::from_query()` to extract parameters from a query string. #846
* `QueryConfig`, similar to `JsonConfig` for customizing error handling of query extractors.

### Changes
### Changed

* `JsonConfig` is now `Send + Sync`, this implies that `error_handler` must be `Send + Sync` too.

Expand All @@ -71,7 +86,7 @@

* Allow to set/override app data on scope level

### Changes
### Changed

* `App::configure` take an `FnOnce` instead of `Fn`
* Upgrade actix-net crates
Expand Down
27 changes: 10 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "actix-web"
version = "1.0.0"
version = "1.0.2"
authors = ["Nikolay Kim <[email protected]>"]
description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust."
readme = "README.md"
Expand Down Expand Up @@ -43,7 +43,7 @@ members = [
]

[features]
default = ["brotli", "flate2-zlib", "client", "fail", "depracated"]
default = ["brotli", "flate2-zlib", "client", "fail"]

# http client
client = ["awc"]
Expand All @@ -68,31 +68,24 @@ ssl = ["openssl", "actix-server/ssl", "awc/ssl"]
# rustls
rust-tls = ["rustls", "actix-server/rust-tls"]

# deprecated middlewares
depracated = ["actix-cors", "actix-identity"]

[dependencies]
actix-codec = "0.1.2"
actix-service = "0.4.0"
actix-service = "0.4.1"
actix-utils = "0.4.1"
actix-router = "0.1.5"
actix-rt = "0.2.2"
actix-web-codegen = "0.1.2"
actix-http = "0.2.3"
actix-http = "0.2.4"
actix-server = "0.5.1"
actix-server-config = "0.1.1"
actix-threadpool = "0.1.1"
awc = { version = "0.2.1", optional = true }

# deprecated middlewares
actix-cors = { version = "0.1.0", optional = true }
actix-identity = { version = "0.1.0", optional = true }

bytes = "0.4"
derive_more = "0.14"
encoding = "0.2"
derive_more = "0.15.0"
encoding_rs = "0.8"
futures = "0.1.25"
hashbrown = "0.3.1"
hashbrown = "0.5.0"
log = "0.4"
mime = "0.3"
net2 = "0.2.33"
Expand All @@ -110,8 +103,8 @@ rustls = { version = "0.15", optional = true }

[dev-dependencies]
actix = { version = "0.8.3" }
actix-http = { version = "0.2.3", features=["ssl", "brotli", "flate2-zlib"] }
actix-http-test = { version = "0.2.0", features=["ssl"] }
actix-http = { version = "0.2.4", features=["ssl", "brotli", "flate2-zlib"] }
actix-http-test = { version = "0.2.2", features=["ssl"] }
rand = "0.6"
env_logger = "0.6"
serde_derive = "1.0"
Expand All @@ -125,7 +118,7 @@ opt-level = 3
codegen-units = 1

[patch.crates-io]
# actix-web = { path = "." }
actix-web = { path = "." }
actix-http = { path = "actix-http" }
actix-http-test = { path = "test-server" }
actix-web-codegen = { path = "actix-web-codegen" }
Expand Down
58 changes: 58 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,64 @@

## 1.0.0

* Extractor configuration. In version 1.0 this is handled with the new `Data` mechanism for both setting and retrieving the configuration

instead of

```rust

#[derive(Default)]
struct ExtractorConfig {
config: String,
}

impl FromRequest for YourExtractor {
type Config = ExtractorConfig;
type Result = Result<YourExtractor, Error>;

fn from_request(req: &HttpRequest, cfg: &Self::Config) -> Self::Result {
println!("use the config: {:?}", cfg.config);
...
}
}

App::new().resource("/route_with_config", |r| {
r.post().with_config(handler_fn, |cfg| {
cfg.0.config = "test".to_string();
})
})

```

use the HttpRequest to get the configuration like any other `Data` with `req.app_data::<C>()` and set it with the `data()` method on the `resource`

```rust
#[derive(Default)]
struct ExtractorConfig {
config: String,
}

impl FromRequest for YourExtractor {
type Error = Error;
type Future = Result<Self, Self::Error>;
type Config = ExtractorConfig;

fn from_request(req: &HttpRequest, payload: &mut Payload) -> Self::Future {
let cfg = req.app_data::<ExtractorConfig>();
println!("config data?: {:?}", cfg.unwrap().role);
...
}
}

App::new().service(
resource("/route_with_config")
.data(ExtractorConfig {
config: "test".to_string(),
})
.route(post().to(handler_fn)),
)
```

* Resource registration. 1.0 version uses generalized resource
registration via `.service()` method.

Expand Down
4 changes: 4 additions & 0 deletions actix-cors/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## [0.1.1] - unreleased

* Bump `derive_more` crate version to 0.15.0

## [0.1.0] - 2019-06-15

* Move cors middleware to separate crate
2 changes: 1 addition & 1 deletion actix-cors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ path = "src/lib.rs"
[dependencies]
actix-web = "1.0.0"
actix-service = "0.4.0"
derive_more = "0.14.1"
derive_more = "0.15.0"
futures = "0.1.25"
6 changes: 3 additions & 3 deletions actix-files/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ path = "src/lib.rs"

[dependencies]
actix-web = { version = "1.0.0", default-features = false }
actix-http = "0.2.3"
actix-service = "0.4.0"
actix-http = "0.2.4"
actix-service = "0.4.1"
bitflags = "1"
bytes = "0.4"
futures = "0.1.25"
derive_more = "0.14"
derive_more = "0.15.0"
log = "0.4"
mime = "0.3"
mime_guess = "2.0.0-alpha"
Expand Down
15 changes: 14 additions & 1 deletion actix-http/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changes

## [0.2.5] - unreleased

### Changed

* Use `encoding_rs` crate instead of unmaintained `encoding` crate

## [0.2.4] - 2019-06-16

### Fixed

* Do not compress NoContent (204) responses #918


## [0.2.3] - 2019-06-02

### Added
Expand Down Expand Up @@ -76,7 +89,7 @@

## [0.1.1] - 2019-04-19

### Changes
### Changed

* Cookie::max_age() accepts value in seconds

Expand Down
8 changes: 4 additions & 4 deletions actix-http/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "actix-http"
version = "0.2.3"
version = "0.2.4"
authors = ["Nikolay Kim <[email protected]>"]
description = "Actix http primitives"
readme = "README.md"
Expand Down Expand Up @@ -56,11 +56,11 @@ bitflags = "1.0"
bytes = "0.4"
byteorder = "1.2"
copyless = "0.1.2"
derive_more = "0.14"
derive_more = "0.15.0"
either = "1.5.2"
encoding = "0.2"
encoding_rs = "0.8"
futures = "0.1.25"
hashbrown = "0.3.0"
hashbrown = "0.5.0"
h2 = "0.1.16"
http = "0.1.17"
httparse = "1.3"
Expand Down
1 change: 1 addition & 0 deletions actix-http/src/encoding/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ impl<B: MessageBody> Encoder<B> {
) -> ResponseBody<Encoder<B>> {
let can_encode = !(head.headers().contains_key(&CONTENT_ENCODING)
|| head.status == StatusCode::SWITCHING_PROTOCOLS
|| head.status == StatusCode::NO_CONTENT
|| encoding == ContentEncoding::Identity
|| encoding == ContentEncoding::Auto);

Expand Down
1 change: 1 addition & 0 deletions actix-http/src/httpcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ impl Response {
STATIC_RESP!(RangeNotSatisfiable, StatusCode::RANGE_NOT_SATISFIABLE);
STATIC_RESP!(ExpectationFailed, StatusCode::EXPECTATION_FAILED);
STATIC_RESP!(UnprocessableEntity, StatusCode::UNPROCESSABLE_ENTITY);
STATIC_RESP!(TooManyRequests, StatusCode::TOO_MANY_REQUESTS);

STATIC_RESP!(InternalServerError, StatusCode::INTERNAL_SERVER_ERROR);
STATIC_RESP!(NotImplemented, StatusCode::NOT_IMPLEMENTED);
Expand Down
15 changes: 7 additions & 8 deletions actix-http/src/httpmessage.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::cell::{Ref, RefMut};
use std::str;

use encoding::all::UTF_8;
use encoding::label::encoding_from_whatwg_label;
use encoding::EncodingRef;
use encoding_rs::{Encoding, UTF_8};
use http::header;
use mime::Mime;

Expand Down Expand Up @@ -59,10 +57,12 @@ pub trait HttpMessage: Sized {
/// Get content type encoding
///
/// UTF-8 is used by default, If request charset is not set.
fn encoding(&self) -> Result<EncodingRef, ContentTypeError> {
fn encoding(&self) -> Result<&'static Encoding, ContentTypeError> {
if let Some(mime_type) = self.mime_type()? {
if let Some(charset) = mime_type.get_param("charset") {
if let Some(enc) = encoding_from_whatwg_label(charset.as_str()) {
if let Some(enc) =
Encoding::for_label_no_replacement(charset.as_str().as_bytes())
{
Ok(enc)
} else {
Err(ContentTypeError::UnknownEncoding)
Expand Down Expand Up @@ -166,8 +166,7 @@ where
#[cfg(test)]
mod tests {
use bytes::Bytes;
use encoding::all::ISO_8859_2;
use encoding::Encoding;
use encoding_rs::ISO_8859_2;
use mime;

use super::*;
Expand Down Expand Up @@ -223,7 +222,7 @@ mod tests {
"application/json; charset=ISO-8859-2",
)
.finish();
assert_eq!(ISO_8859_2.name(), req.encoding().unwrap().name());
assert_eq!(ISO_8859_2, req.encoding().unwrap());
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions actix-multipart/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ path = "src/lib.rs"

[dependencies]
actix-web = { version = "1.0.0", default-features = false }
actix-service = "0.4.0"
actix-service = "0.4.1"
bytes = "0.4"
derive_more = "0.14"
derive_more = "0.15.0"
httparse = "1.3"
futures = "0.1.25"
log = "0.4"
Expand All @@ -31,4 +31,4 @@ twoway = "0.2"

[dev-dependencies]
actix-rt = "0.2.2"
actix-http = "0.2.2"
actix-http = "0.2.4"
8 changes: 4 additions & 4 deletions actix-session/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ default = ["cookie-session"]
cookie-session = ["actix-web/secure-cookies"]

[dependencies]
actix-web = "1.0.0-rc"
actix-service = "0.4.0"
actix-web = "1.0.0"
actix-service = "0.4.1"
bytes = "0.4"
derive_more = "0.14"
derive_more = "0.15.0"
futures = "0.1.25"
hashbrown = "0.3.0"
hashbrown = "0.5.0"
serde = "1.0"
serde_json = "1.0"
time = "0.1.42"
Expand Down
4 changes: 2 additions & 2 deletions actix-web-actors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ path = "src/lib.rs"

[dependencies]
actix = "0.8.3"
actix-web = "1.0.0-rc"
actix-http = "0.2.2"
actix-web = "1.0.0"
actix-http = "0.2.4"
actix-codec = "0.1.2"
bytes = "0.4"
futures = "0.1.25"
Expand Down
Loading

0 comments on commit 93855b8

Please sign in to comment.