-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Update HTTP method requirement example #6062
Conversation
👍 I really like this. |
like it too 👍 Status: Reviewed |
@javiereguiluz @weaverryan What do you think about it? |
path: /news | ||
defaults: { _controller: AppBundle:Main:news } | ||
methods: [GET] | ||
api_show_post: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just asking: should api_show_post
be api_post_show
? I usually do "global preffix" (api_
) + "item" (post
) + "action" (show
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, that makes sense - so there would be a loose standard of api_CONTROLLERNAME_ACTIONNAME
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
👍 This is very well done |
This PR was merged into the 2.3 branch. Discussion ---------- Update HTTP method requirement example | Q | A | --- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.3+ | Fixed tickets | #5583 After many reports (#5779, #5659) of the text no longer matching the example, I think it's time to update the example. The example now uses an API, which is a very common thing now and often needs this feature. API's are already used in the Page Creation article, which is placed before this article, so it shouldn't be too hard to understand. I know that from a REST prespective, HEAD and GET using the same action doesn't seem that great, but it's the only action I could think of that may support 2 methods. Commits ------- 30c2750 Update method requirement example
Thanks Wouter! Changes are merged and route names updated in 87d3167. |
} | ||
|
||
/** | ||
* @Route("/contact") | ||
* @Method({"GET", "POST"}) | ||
* @Route("/api/posts/{id}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dislike posts here, this is unnecessary ambiguous. (post vs posts)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a common practice is to have consistent URLs for your API (to avoid the inconsistency stuff like github's pulls and issues urls). Also, without it the example wouldn't make any sense anymore.
After many reports (#5779, #5659) of the text no longer matching the example, I think it's time to update the example.
The example now uses an API, which is a very common thing now and often needs this feature. API's are already used in the Page Creation article, which is placed before this article, so it shouldn't be too hard to understand.
I know that from a REST prespective, HEAD and GET using the same action doesn't seem that great, but it's the only action I could think of that may support 2 methods.