Commit Graph

173 Commits

Author SHA1 Message Date
Rafael Ávila de Espíndola 189561264c feat(server): Remove Send + Sync requirement for Body in with_graceful_shutdown
Also expand the single threaded example to use that.
2021-10-12 16:47:03 -07:00
Rafael Ávila de Espíndola e96b83e166 test(server): Use a !Send and !Sync HttpBody in an example
The default Body type is used in the client in a Pool, so it has to be
Send. On the server, we can use a !Send type if the executor is single
threaded.

Expand the existing example to show that.
2021-10-12 16:47:03 -07:00
Dai Dao c169cf6ff5 docs(examples): updated imports in client_json example (#2412) 2021-09-16 16:34:10 -07:00
Sean McArthur cedc458cab refactor(lints): fix unused warnings in tests/docs 2021-09-14 16:50:22 -07:00
0x79756b69 7c317fcfd9 docs(example): add a get query method to params example (#2601) 2021-07-21 09:09:38 -07:00
telotic e08e562011 docs(example): support requests to domain names in example http_proxy (#2513) 2021-04-28 17:07:03 -07:00
Anthony Ramine 85d6e03fe1 feat(server): implement forgotten settings for case preserving 2021-04-22 09:50:46 -07:00
kolapapa 26a29b92de docs(examples): upgrade tokio version (#2456) 2021-03-10 10:00:39 -08:00
0x79756b69 a9248422fc docs(examples): use hyper v0.14 and full feature (#2451) 2021-03-08 14:19:24 -08:00
Jim Holmström 3fa434163b docs(examples): gateway: remove extra slash for uri (#2351)
The PathAndQuery already contains the leading slash, which erroneously
sets the proxied path to "//.." and not "/..".
2020-12-03 13:36:32 -08:00
Sean McArthur 31492f8fab feat(upgrade): Moved HTTP upgrades off Body to a new API (#2337)
Closes #2086

BREAKING CHANGE: The method `Body::on_upgrade()` is gone. It is
  essentially replaced with `hyper::upgrade::on(msg)`.
2020-11-19 16:36:12 -08:00
Eliza Weisman c07b5d46df feat(lib): update bytes to 0.6, update http-body (#2339)
This branch updates `bytes` and `http-body` to the latest versions. The
`http-body` version that uses `bytes` 0.6 hasn't been released yet, so
we depend on it via a git dep for now. Presumably Hyper and `http-body`
will synchronize their releases.

Other than that, this is a pretty mechanical update. Should fix the
build and unblock the `h2` update to use vectored writes.
2020-11-19 16:23:32 -08:00
Evan Cameron dc313aece9 docs(example): fix http_proxy comment (#2324) 2020-11-09 08:07:12 -08:00
Sean McArthur 2aad6e18c6 Tokio 0.3 Upgrade (#2319)
Co-authored-by: Urhengulas <johann.hemmann@code.berlin>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2020-11-05 17:17:21 -08:00
Thomas 234f8828bf docs(service): add example of impl Service (#2209)
Add `examples/service_struct_impl.rs`, which provides an up-to-date
example of implementing MakeService and Service on custom types.
The `Svc` struct has a Counter, which demonstrates how to instantiate
shared resources in the `MakeSvc` and pass the resource to the
services. Updates the `examples/README.md` and the doc in
`src/service/mod.rs`.

Closes #1691
2020-06-15 12:01:04 -07:00
Nikolai Kuklin 40e38c4de5 feat(example): read file by chunks in send_file example (#2193) 2020-04-24 13:02:58 -07:00
Sean McArthur c8bdd967a3 style(lib): apply latest rustfmt 2020-02-06 11:41:25 -08:00
Sean McArthur 54f2df2e6b chore(lib): update pretty_env_logger to v0.4 (#2123) 2020-01-29 12:08:43 -08:00
Sean McArthur f0beaccfc7 docs(examples): rename proxy example to gateway 2020-01-29 11:10:48 -08:00
Sean McArthur e3c1cdfaf1 docs(examples): improve README for examples directory 2020-01-29 11:09:21 -08:00
danieleades 0f66461ffd style(lib): address most clippy lints 2020-01-03 09:40:32 -08:00
Vivek Ghaisas ddd5af9c08 style(comments): correct some typos in Rust code comments 2019-12-20 10:16:36 -08:00
Sean McArthur cd21a71693 feat(body): implement HttpBody for Request and Response
When the body type of a `Request` or `Response` implements `HttpBody`,
the `Request` or `Response` itself now implements `HttpBody`.

This allows writing things like `hyper::body::aggregate(req)` instead of
`hyper::body::aggregate(req.into_body())`.

Closes #2067
2019-12-13 10:48:30 -08:00
Euclidr 744e9c3975 docs(server): http_proxy example 2019-12-12 16:59:38 -08:00
Sean McArthur 2735f41dd1 feat(body): add body::aggregate and body::to_bytes functions
Adds utility functions to `hyper::body` to help asynchronously
collecting all the buffers of some `HttpBody` into one.

- `aggregate` will collect all into an `impl Buf` without copying the
  contents. This is ideal if you don't need a contiguous buffer.
- `to_bytes` will copy all the data into a single contiguous `Bytes`
  buffer.
2019-12-06 10:03:05 -08:00
Sean McArthur 2fd8e2de13 feat(body): replace Chunk type with Bytes
Closes #1931

BREAKING CHANGE: All usage of `hyper::Chunk` should be replaced with
  `bytes::Bytes` (or `hyper::body::Bytes`).
2019-12-05 17:22:13 -08:00
Sean McArthur ea12e15095 style(lib): run rustfmt and enforce in CI 2019-12-05 13:55:17 -08:00
Sean McArthur faf6a64531 chore(dependencies): update to http-body 0.3 2019-12-04 16:48:06 -08:00
Sean McArthur baa998929b feat(client): change connectors to return an impl Connection
Instead of returning a tuple `(impl AsyncRead + AsyncWrite, Connected)`,
this adds a new trait, `hyper::client::connect::Connection`, which
allows querying the connection type for a `Connected`.

BREAKING CHANGE: Connectors no longer return a tuple of
  `(T, Connected)`, but a single `T: Connection`.
2019-12-04 16:15:28 -08:00
Sean McArthur e4afa59a74 feat(rt): introduce rt::Executor trait
The `hyper::rt::Executor` trait allows defining custom executors to be
used with hyper's `Client` and `Server`.

Closes #1944

BREAKING CHANGE: Any type passed to the `executor` builder methods must
  now implement `hyper::rt::Executor`.

  `hyper::rt::spawn` usage should be replaced with `tokio::task::spawn`.

  `hyper::rt::run` usage should be replaced with `#[tokio::main]` or
  managing a `tokio::runtime::Runtime` manually.
2019-12-04 11:38:23 -08:00
Sean McArthur 46a0f1762c feat(lib): update Tokio, bytes, http, h2, and http-body 2019-12-04 10:56:34 -08:00
Sean McArthur 28a0e6be78 feat(service): rename Service to HttpService, re-export tower::Service`
The only important trait for a user is the `tower::Service` trait, which
is now available also at `hyper::service::Service`. The other "trait
aliases" are no longer publicly exported, as people thought they had to
implement them.

Also removes dependency on `tower-make`, which is trivial but otherwise
shouldn't affect anyone.

Closes #1959
2019-10-21 11:01:28 -07:00
memoryruins a23e781524 refactor(examples): remove lifetime workaround in send_file example
The lifetime workaround is no longer required due to changes in
rustc. This removes the line and comment from the example.
2019-09-11 09:22:48 -07:00
Sean McArthur b14d12c4f4 docs(examples): add more comments to hello server example 2019-08-30 14:38:22 -07:00
Lucio Franco c344321710 feat(client): provide tower::Service support for clients (#1915) 2019-08-30 12:54:22 -07:00
lzutao 0451093a76 style(lib): use rust 2018 edition idioms (#1910) 2019-08-21 11:22:07 -07:00
lzutao e33cb06eda chore(lib): remove async_await feature gate (#1909)
`async_await` is stabilized in rust-lang/rust#63209.
2019-08-21 11:09:14 -07:00
Lucio Franco 637d4d43af feat(service): use tower_service::Service for hyper::service 2019-08-20 12:01:06 -07:00
Yotam Ofek a6796d071d refactor(server): work around deprecation of poll_accept method in tokio (#1890) 2019-08-14 11:46:49 -07:00
Daiki Mizukami 5ba5c917a0 refactor(rt): remove re-export of tokio::main (#1879)
Closes #1878.

BREAKING CHANGE: Replace all usage of `rt::main` with `tokio::main`.
2019-07-22 10:06:36 -07:00
Weihang Lo 4a7a40aac7 docs(examples): formatting and refactoring 2019-07-16 10:08:22 -07:00
Weihang Lo 5d7ad841f1 docs(examples): move web_api to examples folder 2019-07-16 10:08:22 -07:00
Weihang Lo 9e8a71fc15 docs(examples): update send_file example to async/await 2019-07-16 10:08:22 -07:00
Weihang Lo b1bbede179 docs(examples): update upgrade example to async/await 2019-07-15 11:35:33 -07:00
Weihang Lo 111a8a0eb0 docs(examples): update single_threaded example to async/await 2019-07-15 11:35:33 -07:00
Weihang Lo e58ad1e022 docs(examples): update state example to async/await 2019-07-15 11:35:33 -07:00
Weihang Lo 31406cef0f docs(examples): update proxy example to async/await 2019-07-15 11:35:33 -07:00
Sean McArthur a80f7f5ee8 chore(lib): individually disable tests and examples that aren't updated 2019-07-12 13:44:03 -07:00
messense 871ed05ff1 docs(examples): Update params example to use async await 2019-07-12 10:57:27 -07:00
messense ea375902c6 docs(examples): Update multi_server example to use async await 2019-07-12 10:43:39 -07:00