Skip to content

Update examples to async/await #1871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 15, 2019
Merged

Update examples to async/await #1871

merged 5 commits into from
Jul 15, 2019

Conversation

weihanglo
Copy link
Contributor

What

#1849

Update following examples to async/await version and move them from examples_disabled to examples folder.

How to test

proxy

This is a example for a proxy server. It would proxy every requests from localhost:3000 to localhost:3001. To test its functionalities, first

  • Launch the proxy server by running cargo run --example proxy
  • Launch the target server by running cargo run --example hello
  • Run curl localhost:3001 and response Hello World!

single_threaded & state

These two examples are counterparts of each other. Only in singled_threaded example can Rc (not Send type) be used.

  • Run cargo run --example state to launch the server.
  • curl localhost:3000 and check if the request counter increases correctly.
  • Run cargo run --example singled_threaded to launch the server.
  • curl localhost:3000 and check if the request counter increases correctly.

upgrades

This example demos HTTP upgrading. To test it, just follow the steps:

  • Run cargo run --example upgrades to launch the server.
  • The console would output followings
    client[foobar] sent
    server[foobar] recv: Ok("foo=bar")
    server[foobar] sent
    client[foobar] recv: Ok("barr=foo")
    
  • The server then shutdowns gracefully.

@seanmonstar seanmonstar merged commit 7cdfd3d into hyperium:master Jul 15, 2019
@weihanglo weihanglo deleted the fix-examples branch July 15, 2019 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants