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

chore(volo-http): use elegant way for creating method router #410

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

wfly1998
Copy link
Member

@wfly1998 wfly1998 commented Apr 8, 2024

Motivation

The previous way for creating MethodRouter is ugly, this PR updates it with a elegant way.

Previous

# foo is a handler, while Bar is a service

let router = Router::new()
    .route("/", get(foo))
    .route(
        "/index",
        MethodRouter::builder()
            .get(from_handler(foo))
            .post(from_service(Bar))
            .build(),
    )
    .route("/srv", get(from_service(Bar)));

Latest

let router = Router::new()
    .route("/", get(foo))
    .route("/index", get(foo).post_service(Bar))
    .route("/srv", get_service(Bar));

Solution

Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
@wfly1998 wfly1998 requested review from a team as code owners April 8, 2024 14:41
@wfly1998 wfly1998 merged commit d4e6401 into cloudwego:main Apr 8, 2024
13 checks passed
@wfly1998 wfly1998 deleted the feat/elegant-method branch April 8, 2024 14:50
@wfly1998 wfly1998 mentioned this pull request Apr 8, 2024
15 tasks
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

2 participants