Skip to content

Commit a6cf59a

Browse files
authored
Merge branch 'seanmonstar:master' into local-socketaddr
2 parents 7e1dff3 + e2f4501 commit a6cf59a

File tree

9 files changed

+134
-85
lines changed

9 files changed

+134
-85
lines changed

.github/workflows/ci.yml

+10-33
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,14 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v1
15+
uses: actions/checkout@v3
1616

1717
- name: Install rust
18-
uses: actions-rs/toolchain@v1
18+
uses: dtolnay/rust-toolchain@stable
1919
with:
20-
toolchain: stable
2120
components: rustfmt
22-
profile: minimal
23-
override: true
2421

25-
- name: cargo fmt -- --check
26-
uses: actions-rs/cargo@v1
27-
with:
28-
command: fmt
29-
args: --all -- --check
22+
- run: cargo fmt --all --check
3023

3124
test:
3225
name: Test
@@ -50,48 +43,32 @@ jobs:
5043
- build: compression
5144
features: "--features compression"
5245

53-
5446
steps:
5547
- name: Checkout
56-
uses: actions/checkout@v1
48+
uses: actions/checkout@v3
5749

5850
- name: Install rust
59-
uses: actions-rs/toolchain@v1
51+
uses: dtolnay/rust-toolchain@master
6052
with:
6153
toolchain: ${{ matrix.rust || 'stable' }}
62-
profile: minimal
63-
override: true
6454

6555
- name: Test
66-
uses: actions-rs/cargo@v1
67-
with:
68-
command: test
69-
args: ${{ matrix.features }}
56+
run: cargo test ${{ matrix.features }}
7057

7158
- name: Test all benches
7259
if: matrix.benches
73-
uses: actions-rs/cargo@v1
74-
with:
75-
command: test
76-
args: --benches ${{ matrix.features }}
60+
run: cargo test --benches ${{ matrix.features }}
7761

7862
doc:
7963
name: Build docs
8064
needs: [style, test]
8165
runs-on: ubuntu-latest
8266
steps:
8367
- name: Checkout
84-
uses: actions/checkout@v1
68+
uses: actions/checkout@v3
8569

8670
- name: Install Rust
87-
uses: actions-rs/toolchain@v1
88-
with:
89-
profile: minimal
90-
toolchain: nightly
91-
override: true
71+
uses: dtolnay/rust-toolchain@nightly
9272

9373
- name: cargo doc
94-
uses: actions-rs/cargo@v1
95-
with:
96-
command: rustdoc
97-
args: -- -D broken_intra_doc_links
74+
run: cargo rustdoc -- -D broken_intra_doc_links

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### v0.3.4 (March 31, 2023)
2+
3+
- **Fixes**:
4+
- `multipart::Part` data is now streamed instead of buffered.
5+
- Update dependency used for `multipart` filters.
6+
17
### v0.3.3 (September 27, 2022)
28

39
- **Fixes**:

Cargo.toml

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "warp"
3-
version = "0.3.3" # don't forget to update html_root_url
3+
version = "0.3.4" # don't forget to update html_root_url
44
description = "serve the web at warp speeds"
55
authors = ["Sean McArthur <[email protected]>"]
66
license = "MIT"
@@ -27,7 +27,7 @@ hyper = { version = "0.14.19", features = ["stream", "server", "http1", "http2",
2727
log = "0.4"
2828
mime = "0.3"
2929
mime_guess = "2.0.0"
30-
multipart = { version = "0.18", default-features = false, features = ["server"], optional = true }
30+
multer = { version = "2.1.0", optional = true }
3131
scoped-tls = "1.0"
3232
serde = "1.0"
3333
serde_json = "1.0"
@@ -37,24 +37,25 @@ tokio-stream = "0.1.1"
3737
tokio-util = { version = "0.7", features = ["io"] }
3838
tracing = { version = "0.1.21", default-features = false, features = ["log", "std"] }
3939
tower-service = "0.3"
40-
tokio-tungstenite = { version = "0.17", optional = true }
40+
tokio-tungstenite = { version = "0.18", optional = true }
4141
percent-encoding = "2.1"
4242
pin-project = "1.0"
4343
tokio-rustls = { version = "0.23", optional = true }
44-
rustls-pemfile = "0.2"
44+
rustls-pemfile = "1.0"
4545

4646
[dev-dependencies]
4747
pretty_env_logger = "0.4"
48-
tracing-subscriber = "0.2.7"
48+
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
4949
tracing-log = "0.1"
5050
serde_derive = "1.0"
5151
handlebars = "4.0"
5252
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
5353
tokio-stream = { version = "0.1.1", features = ["net"] }
54-
listenfd = "0.3"
54+
listenfd = "1.0"
5555

5656
[features]
5757
default = ["multipart", "websocket"]
58+
multipart = ["multer"]
5859
websocket = ["tokio-tungstenite"]
5960
tls = ["tokio-rustls"]
6061

@@ -96,3 +97,8 @@ required-features = ["websocket"]
9697

9798
[[example]]
9899
name = "query_string"
100+
101+
102+
[[example]]
103+
name = "multipart"
104+
required-features = ["multipart"]

examples/multipart.rs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use futures_util::TryStreamExt;
2+
use warp::multipart::FormData;
3+
use warp::Buf;
4+
use warp::Filter;
5+
6+
#[tokio::main]
7+
async fn main() {
8+
// Running curl -F [email protected] 'localhost:3030/' should print [("file", ".gitignore", "\n/target\n**/*.rs.bk\nCargo.lock\n.idea/\nwarp.iml\n")]
9+
let route = warp::multipart::form().and_then(|form: FormData| async move {
10+
let field_names: Vec<_> = form
11+
.and_then(|mut field| async move {
12+
let contents =
13+
String::from_utf8_lossy(field.data().await.unwrap().unwrap().chunk())
14+
.to_string();
15+
Ok((
16+
field.name().to_string(),
17+
field.filename().unwrap().to_string(),
18+
contents,
19+
))
20+
})
21+
.try_collect()
22+
.await
23+
.unwrap();
24+
25+
Ok::<_, warp::Rejection>(format!("{:?}", field_names))
26+
});
27+
warp::serve(route).run(([127, 0, 0, 1], 3030)).await;
28+
}

examples/todos.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mod filters {
3838
/// The 4 TODOs filters combined.
3939
pub fn todos(
4040
db: Db,
41-
) -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
41+
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
4242
todos_list(db.clone())
4343
.or(todos_create(db.clone()))
4444
.or(todos_update(db.clone()))
@@ -48,7 +48,7 @@ mod filters {
4848
/// GET /todos?offset=3&limit=5
4949
pub fn todos_list(
5050
db: Db,
51-
) -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
51+
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
5252
warp::path!("todos")
5353
.and(warp::get())
5454
.and(warp::query::<ListOptions>())
@@ -59,7 +59,7 @@ mod filters {
5959
/// POST /todos with JSON body
6060
pub fn todos_create(
6161
db: Db,
62-
) -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
62+
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
6363
warp::path!("todos")
6464
.and(warp::post())
6565
.and(json_body())
@@ -70,7 +70,7 @@ mod filters {
7070
/// PUT /todos/:id with JSON body
7171
pub fn todos_update(
7272
db: Db,
73-
) -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
73+
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
7474
warp::path!("todos" / u64)
7575
.and(warp::put())
7676
.and(json_body())
@@ -81,7 +81,7 @@ mod filters {
8181
/// DELETE /todos/:id
8282
pub fn todos_delete(
8383
db: Db,
84-
) -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
84+
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
8585
// We'll make one of our endpoints admin-only to show how authentication filters are used
8686
let admin_only = warp::header::exact("authorization", "Bearer admin");
8787

0 commit comments

Comments
 (0)