-
Notifications
You must be signed in to change notification settings - Fork 0
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
Port miniserve to async #17
base: 00-chat-route-b
Are you sure you want to change the base?
Conversation
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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Change the
miniserve
API to use Rust's async features via Tokio. Unfortunately, this breaks theserver
crate, so CI is failing.