[erlang-questions 13] Re: [erlang-questions] Webmachine questions

Alain O'Dea <>
Fri Mar 25 21:00:35 CET 2011

Hi Ulf:

You won't actually need two delete functions, since process_post can
delegate to your delete handler if the correct form parameter is

It's a compromise.  Modifying the webmachine_decision_core to handle
protocol tunneling would be a serious challenge.  An alternative would
be to have to have an HTTP proxy in front of webmachine that
understands your representation of tunneling.

Overall a proxy would be epically more complicated and operational
problematic than a small amount of branching within a resource.  A
much better alternative is to implement a generic webmachine resource
that accepts a callback module whose functions perform the
application-level request processing.  That way you could effectively
have a generic HTTP method tunneling webmachine resource :)

None of this is necessary if you use XHR to send your forms since it
allows you to set the method.


On Fri, Mar 25, 2011 at 1:58 AM, Ulf Angermann
<> wrote:
> Hi Alan,
> thanks for answer, but i am not really happy with your first one, because
> than i have to implement two "delete" functions. In my opinion it would be
> nicer, if i could change the method from POST to DELETE. Than i could handle
> the tunneld delete as the "normal" one.
> I will look at zotonic if i find something there, thank you.
> Thanks,
> Ulf
> 2011/3/24 Alain O'Dea <>
>> Hi Ulf:
>> On 2011-03-24, at 5:45, u a <> wrote:
>> > Hello,
>> >
>> > i am working on a small project, where i am using webmachine.
>> > Everything works fine, but know i have some question regarding the
>> > tool.
>> >
>> > 1. Tunneld delete throw POST (HTML forms)
>> >
>> > Because of the limitation of the browser, i have to tunnel a delete
>> > request throw a post request to webmachine.
>> > When i look in the trace, great tool :-) , my request comes to the
>> > decision M16 where the question is asked if this is a DELETE method or
>> > not.
>> > The answer is false , because it is a POST and not a DELETE method.
>> >
>> > Is it possible to change the method from a POST to a DELETE or which
>> > kind of solution is the best?
>> >
>> > 2. Getting the protocol for the location
>> >
>> > When i create a location header or a redirect, i want to decide of the
>> > underlying socket, which kind of protocol i have to use (HTTP or HTTPS
>> > for instance. I found that the socket is part of webmachine_request,
>> > but there is no function inside wrq to retrieve this information.
>> >
>> > Is there an easy way to detect the protocol which is used inside the
>> > resource?
>> >
>> > Thanks for your help,
>> > Ulf
>> >
>> 1. Your resource's process_post function needs to handle this.  Since you
>> are tunneling DELETE through POST it is actually POST that you need to
>> handle.  I am guessing your tunneling is based on a form param called
>> method.  Read that and branch in process_post :)
>> 2. No idea off the top of my head how to get the protocol.  I don't think
>> vanilla webmachine wrq has this info.  I'm pretty sure it is visible in
>> Zotonic webmachine resources though

More information about the erlang-questions mailing list