Skip to content

Refactor API #350

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 65 commits into from
Nov 27, 2019
Merged

Refactor API #350

merged 65 commits into from
Nov 27, 2019

Conversation

yoshuawuyts
Copy link
Member

This is a whole set of related changes, addressing most of what was laid out in #336. This disables a lot of work, but sets us up to carefully reintroduce later.

The biggest changes are that we have several core constructs:

  • Server is the main application struct (formerly called App).
  • Endpoint (trait) is the endpoint people work with.
  • Request is what is is passed to Endpoint and represents an incoming request. (formerly called Context).
  • Response is what is returned from Endpoint and represents an outgoing response.

Both Request and Response operate with AsyncRead, and have shorthand methods to send and receive json, forms, querystrings, etc.

I believe this should dramatically streamline the experience of using Tide, and overall make writing HTTP services a lot nicer!

Examples

echo server

let app = tide::new();
app.at("/echo").get(|req| async move { req });
app.listen("localhost:8080").await?;

hello world

let app = tide::new();
app.at("/echo").get(|_| async move { "hello world" });
app.listen("localhost:8080").await?;

Screenshot

Screenshot_2019-11-04 tide - Rust(2)

@yoshuawuyts yoshuawuyts mentioned this pull request Nov 12, 2019
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Multipart was including the `iron` and `nickel` frameworks, which is
simply too much. This patch disables it. Thanks!

Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
yoshuawuyts and others added 9 commits November 20, 2019 01:03
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Remove unneeded imports and don't use select
@yoshuawuyts yoshuawuyts marked this pull request as ready for review November 27, 2019 12:29
@yoshuawuyts
Copy link
Member Author

Tests pass; has also been reviewed by a few folks. Going to go ahead and merge!

@yoshuawuyts yoshuawuyts merged commit 0c529ce into master Nov 27, 2019
@yoshuawuyts yoshuawuyts deleted the api-cleanup branch November 27, 2019 12:38
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.

4 participants