-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
method with Dream.form_tag #74
Comments
How about two separate arguments, |
It seems even better ! Thanks ! |
Added by the linked commit :) Thanks for the request/feedback. |
@aantron the HTML So the type of Alternatively, it is common to add an input containing the method to use and change the HTTP method of the request with the value of this input before it is routed to the handler/controller. Opium has a middleware for this: https://github.com/rgrinberg/opium/blob/master/opium/src/middlewares/middleware_method_override.ml As well as Plug: https://hexdocs.pm/plug/Plug.MethodOverride.html |
@tmattio the link, https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Form#attributes_for_form_submission, also says that So far, my idea was to let the Dream user use any method, and leave HTML compliance up to them on this matter. I am aware that forms officially support only Method override seems like a separate issue, and the way I typed What do you suggest in light of |
Makes sense! I didn't know if it was an intentional deviation from the spec or an oversight, so I took the liberty to ping you 🙂 I never encountered If you're willing to handle method overrides in Dream directly, I could propose a PR with a new built-in middleware and an input field in the |
What's the natural use case for method override these days? I assume it's mainly for bypassing firewalls, but I'm also under the impression that firewalls which block methods other than GET and POST are gradually being replaced (or reconfigured), so method override is becoming less and less needed over time. I wasn't able to find much information on real usage, however, so I'd be glad to learn :) I opened #76 Method override middleware to continue the discussion of method override there. |
I've been using it to decouple what is an HTML implementation detail from the design of server APIs. A common pattern for CRUD APIs is to use different HTTP methods for the same endpoint:
This is not compatible with HTML forms, but I don't want the design of my APIs to be the result of a limitation in the HTML spec, so I use method overrides to work around this instead. Apart from this, I am not familiar with specific use cases that are technically blocked without the support of method overrides. |
FYI the upcoming release includes #201, in which |
It could be useful to be able to select between
POST
andGET
for the method attribute of the<form>
tag returned byDream.form_tag
. AndGET
could not use CSRF token. This would be useful when you want to allow sharing URLs for queries.The text was updated successfully, but these errors were encountered: