Skip to content
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

feat: introduce volo-http crate #264

Merged
merged 12 commits into from Nov 28, 2023
Merged

feat: introduce volo-http crate #264

merged 12 commits into from Nov 28, 2023

Conversation

wfly1998
Copy link
Member

To support HTTP protocol, we introduce a crate volo-http, which is greatly inspired by axum.

An example is provided in examples/src/http/simple.rs.

@wfly1998 wfly1998 requested review from a team as code owners November 24, 2023 13:09
@wfly1998
Copy link
Member Author

Maybe the README.md needs updating too 🤔

PureWhiteWu
PureWhiteWu previously approved these changes Nov 24, 2023
examples/Cargo.toml Outdated Show resolved Hide resolved
volo-http/Cargo.toml Outdated Show resolved Hide resolved
volo-http/src/lib.rs Outdated Show resolved Hide resolved
Signed-off-by: Gwo Tzu-Hsing <gotzehsing@gmail.com>
Signed-off-by: Zheng Li <875543533@qq.com>
Signed-off-by: bobozhengsir <bobozhengsir@gmail.com>
Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
Signed-off-by: Gwo Tzu-Hsing <gotzehsing@gmail.com>
Signed-off-by: Zheng Li <875543533@qq.com>
Signed-off-by: bobozhengsir <bobozhengsir@gmail.com>
Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
The `matchit::Router` cannot be converted to `Iterator`, so using
`matchit::Router<DynService>` is not convenient enough.

To solve the problem, we refer to the implementation of `axum` and
introduce a `RouteId` as a bridge, the `matchit::Router` only handles
some IDs and each ID corresponds to a `DynService`.

Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
With tie type `Route`, it can support `Service`, `Handler` and so on.

Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
With this commit, there is no need to keep `HttpContext` in handler
function.  Like axum, anything with `FromContext` or `FromRequest`
trait can be used as arguments of a handler.

Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
Note that `hyper` v1.0.0-rc4 replaces IO traits from `tokio` with its
IO traits in `hyper::rt`.  To solve the building problem, we can
introduce `TokioIo` from `hyper-util` and wrap the `DefaultIncoming`
by the `TokioIo`.

Also, the `volo-grpc` uses `hyper` v0.14 with its auto-version
(using both http1 and http2) and graceful shutdown, but the latest
`hyper` and `hyper-util` cannot use the both features at the same
time, so the version of `hyper` in `volo` has not been upgraded.

Ref:
- hyperium/hyper@f9f65b7
- hyperium/hyper#3013
- hyperium/hyper#2862

Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
质疑 axum,理解 axum,成为 axum

Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
With the previous codes, server could not stop immediately after
pressing Ctrl+C, but waited until timeout before exiting.

This commit uses the same approach as "volo-thrift" and the problem
has been resolved.

Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
This commit supports fallback in `Router` and `MethodRouter`. With
`fallback`, when no route or method can handle the request, the
`fallback` will be called and the specified response will be returned.

Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
This commit adds a `TimeoutLayer` for `volo-http` which can use a
function as a callback and when timeout occurs, it will return a
response by the callback.

Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
@wfly1998 wfly1998 merged commit 6145eed into main Nov 28, 2023
11 checks passed
@wfly1998 wfly1998 deleted the feat/volo-http branch November 28, 2023 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants