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

Add macro for route handler accepting all HTTP methods #3263

Open
tp971 opened this issue Jan 24, 2024 · 13 comments · May be fixed by #3310
Open

Add macro for route handler accepting all HTTP methods #3263

tp971 opened this issue Jan 24, 2024 · 13 comments · May be fixed by #3310
Assignees
Labels
A-codegen project: actix-web-codegen C-feature Category: new functionality good-first-issue easy to pick up for newcomers

Comments

@tp971
Copy link

tp971 commented Jan 24, 2024

As discussed in #3259, implement macros like #[any("...")] and #[route("...", method = any)] to create route handlers accepting all HTTP methods (which is currently only possible with something like app.route("...", web::route().to(handler)))

@robjtede robjtede added A-codegen project: actix-web-codegen C-feature Category: new functionality good-first-issue easy to pick up for newcomers labels Jan 24, 2024
@sabinonweb
Copy link

I will like to take this issue, can you help me figure out the initials and the codebase?

@sabinonweb
Copy link

Or provide more information

@robjtede
Copy link
Member

You can look inside the actix-web-codegen crate source. I'd recommend adding a trybuild test first using the format mentioned in the OP issue and discussion post.

@sabinonweb
Copy link

When I tried to run trybuild tests using cargo test --test trybuild or even just cargo test, it shows that 0 tests were run. Am i making a mistake? @robjtede

@robjtede
Copy link
Member

robjtede commented Mar 15, 2024

Good point. The trybuild tests only run on our MSRV. So Rust 1.72.

@sabinonweb
Copy link

I don't know if it's a dumb question buy may I ask whether the HTTP methods are imported from inbuilt libraries or defined within the source code itself. If they are defined please could you specify where? @robjtede

@sabinonweb
Copy link

I figured out that it is exported. Now, I will work on defining ALL method kind of thing because an error related to naming conflict was generated

@sabinonweb
Copy link

Can you guide me on that a little @robjtede ? It's been quite a task

@robjtede
Copy link
Member

robjtede commented Mar 15, 2024

@sabinonweb Do you want to open a draft PR so I can see where you've gotten to?

@sabinonweb
Copy link

@robjtede please have a look

@sabinonweb

This comment has been minimized.

@robjtede
Copy link
Member

I left some comments earlier. See the PR.

@robjtede robjtede linked a pull request Mar 16, 2024 that will close this issue
5 tasks
@sabinonweb
Copy link

Would adding methods in with_any_methods, similar to with_methods work @robjtede

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen project: actix-web-codegen C-feature Category: new functionality good-first-issue easy to pick up for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants