Is there an easy way to have yesod read a POST request as a PUT or DELETE when it has a special parameter: _method=DELETE? And render forms with it?
1 Answer
Yesod uses the methodOverride middleware by default which allows this. When I use this approach, I just put it into the action attribute of the form, e.g.:
<form method=post action=@{SomeRouteR}?_method=DELETE>
-
-
It works with a standard setup, e.g. fpcomplete.com/user/snoyberg/random-code-snippets/…. You might have different middlewares configured, but I can't tell from the information you've provided. Apr 9, 2014 at 4:33
-
1I just ran into the fact myself that the scaffolded site does not have methodOverride enabled by default. If that's the issue you're running into, you need to edit your Application.hs, find the code that says
logWare app, and replace it withlogWare $ methodOverride app. You'll need to include an import forNetwork.Wai.Middleware.MethodOverrideas well. Apr 9, 2014 at 10:53 -