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

支持命名路由 #892

Open
micross opened this issue Sep 7, 2024 · 0 comments
Open

支持命名路由 #892

micross opened this issue Sep 7, 2024 · 0 comments

Comments

@micross
Copy link

micross commented Sep 7, 2024

能否添加命名路由的支持,第二个参数作为路由的名称,类似这样:

Router::new()
    .path("writers")
    .get(list_writers, "list_writers")
    .post(create_writer, "create_writer")
    .push(
        Router::with_path("<id>")
            .get(show_writer, "show_writer")
            .patch(edit_writer, "edit_writer")
            .delete(delete_writer, "delete_writer")
            .push(Router::with_path("articles").get(list_writer_articles)),
    );

然后再添加个函数route,通过名称获取路径,类似:

Router::route("list_writers") 返回 /writers
Router::route("create_writer") 返回 /writers
Router::route("show_writer", 1) 返回 /writers/1

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

No branches or pull requests

1 participant