1

We're using Grails for building RESTful services which we'll call from browser clients using HTML forms, the problem is that forms only support GET and POST, so we're not sure how to handle PUT and DELETE.

miku
  • 181,842
  • 47
  • 306
  • 310
raffian
  • 31,267
  • 26
  • 103
  • 174
  • [Are the PUT, DELETE, HEAD, etc methods available in most web browsers?](http://stackoverflow.com/questions/165779/are-the-put-delete-head-etc-methods-available-in-most-web-browsers) – Rob Hruska Aug 09 '11 at 14:24
  • No, not in forms. Once you use scripting + XHR, yes. – Julian Reschke Aug 09 '11 at 15:11

1 Answers1

5

Grails template tags can help you there:

However, issuing a request with a method other than GET or POST from a regular browser is not possible without some help from Grails. When defining a form you can specify an alternative method such as DELETE:

<g:form controller="book" method="DELETE">
..  
</g:form>

Grails will send a hidden parameter called _method, which will be used as the request's HTTP method. Another alternative for changing the method for non-browser clients is to use the X-HTTP-Method-Override to specify the alternative method name.

Via: http://www.grails.org/doc/latest/guide/13.%20Web%20Services.html

miku
  • 181,842
  • 47
  • 306
  • 310
  • Doesn't matter if it tunnels, it's invisible to my application since Grails framework handles the details, – raffian Aug 09 '11 at 15:21