Port miniserve to async#17
Open
willcrichton wants to merge 3 commits into
Open
Conversation
willcrichton
commented
Jul 30, 2024
| pub trait Handler: Fn(Request) -> Response + Send + Sync + 'static {} | ||
| pub trait Handler: Fn(Request) -> Self::Future + Send + Sync + 'static { | ||
| type Future: Future<Output = Response> + Send + Sync + 'static; | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Take a close look at the change to the Handler trait. Previously, a handler was a function that took a request and returned a response. Now, a handler is a function that takes a request and returns a future which eventually returns a response.
12e4e2b to
705d63d
Compare
bf3156c to
f4561fc
Compare
473a30a to
eda5cdb
Compare
f4561fc to
43849b2
Compare
willcrichton
commented
Aug 26, 2024
| pub fn run(self) { | ||
| let listener = | ||
| TcpListener::bind("127.0.0.1:3000").expect("Failed to connect to 127.0.0.1:3000"); | ||
| pub async fn run(self) { |
Contributor
Author
There was a problem hiding this comment.
Note that the run function is now asynchronous, indicated by the async keyword.
eda5cdb to
a1e8a88
Compare
43849b2 to
799f47d
Compare
a1e8a88 to
1d89da8
Compare
1d89da8 to
a5669b6
Compare
799f47d to
46170d7
Compare
46170d7 to
48c19c4
Compare
33cee9f to
ddc5378
Compare
ddc5378 to
ed6ea06
Compare
548d86e to
802a658
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change the
miniserveAPI to use Rust's async features via Tokio. Unfortunately, this breaks theservercrate, so CI is failing. Help me finish the port.