14 Commits

Author SHA1 Message Date
kolapapa
297a068454 docs(examples): upgrade tokio version (#2456) 2021-03-10 10:00:39 -08:00
0x79756b69
34085afef6 docs(examples): use hyper v0.14 and full feature (#2451) 2021-03-08 14:19:24 -08:00
Thomas
55ba000746 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
203621e3be feat(example): read file by chunks in send_file example (#2193) 2020-04-24 13:02:58 -07:00
Sean McArthur
2983395d63 chore(lib): update pretty_env_logger to v0.4 (#2123) 2020-01-29 12:08:43 -08:00
Sean McArthur
5c6536317c docs(examples): improve README for examples directory 2020-01-29 11:09:21 -08:00
Euclidr
bfda390617 docs(server): http_proxy example 2019-12-12 16:59:38 -08:00
Sean McArthur
ced949cb6b feat(server): allow !Send Servers
Until this commit, servers have required that `Service` and their
`Future` to be `Send`, since the server needs to spawn some internal
tasks to an executor, and by default, that is `tokio::spawn`, which
could be spawning to a threadpool. This was true even if the user were
certain there was no threadpool involved, and was instead using a
different single-threaded runtime, like
`tokio::runtime::current_thread`.

This changes makes all the server pieces generic over an `E`, which is
essentially `Executor<PrivateTypes<Server::Future>>`. There's a new set
of internal traits, `H2Exec` and `NewSvcExec`, which allow for the type
signature to only show the generics that the user is providing. The
traits cannot be implemented explicitly, but there are blanket
implementations for `E: Executor<SpecificType>`. If the user provides
their own executor, it simply needs to have a generic `impl<F>
Executor<F> for MyExec`. That impl can have bounds deciding whether to
require `F: Send`. If the executor does require `Send`, and the
`Service` futures are `!Send`, there will be compiler errors.

To prevent a breaking change, all the types that gained the `E` generic
have a default type set, which is the original `tokio::spawn` executor.
2018-10-16 13:21:45 -07:00
Ahmed Charles
9fa721df9e docs(examples): add proxy example 2018-10-02 10:07:31 -07:00
Sean McArthur
ae34a86cc3 docs(examples): add a stateful server example with a request counter 2018-07-06 15:24:01 -07:00
ozgurakkurt
e06dc52ef6 docs(client): Add client_json example
Closes #1581
2018-07-03 14:41:50 -07:00
Sean McArthur
fea29b29e2 feat(http1): Add higher-level HTTP upgrade support to Client and Server (#1563)
- Adds `Body::on_upgrade()` that returns an `OnUpgrade` future.
- Adds `hyper::upgrade` module containing types for dealing with
  upgrades.
- Adds `server::conn::Connection::with_upgrades()` method to enable
  these upgrades when using lower-level API (because of a missing
  `Send` bound on the transport generic).
- Client connections are automatically enabled.
- Optimizes request parsing, to make up for extra work to look for
  upgrade requests.
  - Returns a smaller `DecodedLength` type instead of the fatter
    `Decoder`, which should also allow a couple fewer branches.
  - Removes the `Decode::Ignore` wrapper enum, and instead ignoring
    1xx responses is handled directly in the response parsing code.

Ref #1563 

Closes #1395
2018-06-14 13:39:29 -07:00
Aaron Riekenberg
7eca445ff9 docs(examples): Update send_file example to use tokio-fs 2018-06-04 09:59:42 -07:00
meven
2415ce96e1 docs(examples): add README for examples directory
Closes #1511
2018-05-30 00:39:05 +02:00