title: REST service in Ejabberd; DELETE and PUT Method
body: <p>I am using the request handlers found in ejabberd to build a REST service.</p>
  
  <p>Is it possible to invoke the ejabberd request_handlers with a PUT and DELETE HTTP Method? If so how?</p>
  
  <p>I have been able to invoke request_handlers with POST and GET HTTP Methods successfully but can't seem to be able to do the same with PUT or DELETE.</p>
  
  <p>Every time I try to do a PUT or DELETE I get in return a "400 Bad Request"</p>
  
  <p>I am using curl to do the testing </p>
  
  <pre><code>curl -i -X &lt;METHOD&gt;  &lt;URL&gt;
  </code></pre>
  
  <p>for GET, PUT and DELETE, and </p>
  
  <pre><code>curl -i -X &lt;METHOD&gt;  &lt;URL&gt; -d &lt;POSTBody&gt;
  </code></pre>
  
  <p>for POST (also tried it for PUT and DELETE)</p>
  
  <p>I have configured the request handlers in ejabberd.cfg with the following</p>
  
  <pre><code>{listen,
   [
    (...)
    {5280, ejabberd_http, [
                       http_bind,
                       http_poll,
                       web_admin,
                      {request_handlers, [
                              {["hello_world"], mod_http_hello_world},
                              {["users"], mod_http_registered_users},
                              {["api"],mod_http_rest_api}
                      ]}
     ]}
  </code></pre>
  
  <p>and the mod_http_rest_api</p>
  
  <pre><code>-module(mod_http_rest_api).
  -define(EJABBERD_DEBUG, true).
  
  -behavior(gen_mod).
  
  -export([start/2,stop/1,process/2]).
  
  -include("ejabberd.hrl").
  -include("jlib.hrl").
  -include("ejabberd_http.hrl").
  
  start(_Host, _Opts) -&gt;
    ?INFO_MSG("mod_http_rest_api: Starting",[]),
    ok.
  
   stop(_Host) -&gt;
     ?INFO_MSG("mod_http_rest_api: Stoping",[]),
     ok.
  
   process(List,#request{method = Method}) -&gt;
      StrMethod = atom_to_list(Method),
      List ++ " was invoked with method " ++ StrMethod.
  </code></pre>