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

Alain O'Dea alain.odea@REDACTED
Sat Mar 26 13:26:39 CET 2011


Hi Ulf:

Modifying the source of a framework to achieve your goals has serious drawbacks.  It can introduce subtle bugs and can make updating the framework to follow security or performance fixes much harder.

More importantly there is no advantage in modifying webmachine in this way since the behaviour you are looking for is cleanly achievable in resource code.

I strongly advise you to reconsider altering the framework source.  Having made that mistake myself and having experienced the maintenance nightmare it creates in a real product I want to save you the pain of experiencing it yourself :)

Either way, plot out the pros and cons and clearly document the rationale for whatever decision you make.

Best regards,
Alain


On 2011-03-26, at 2:24, Ulf Angermann <uangermann@REDACTED> wrote:

> Hi Alain,
> 
> you are right that i have my delete logic in seperate handler, but nevertheless it will POST and not a DELETE.
> 
> I think about a solution, that i enhance the webmachine_mochiweb modul, so it will do the work for me. 
> In this modul i will ask when it is a post and there is a method=delete tunneld i will create a DELETE method. We'll see if this will work for me.
> 
> XHR isn't a solution for me, because i want to use plain HTML without any JS, As i understood, you can't use it without. 
> 
> I will post my question to the webmachine mailing list, too. 
> 
> Thanks,
> Ulf
> 
> 
> 2011/3/25 Alain O'Dea <alain.odea@REDACTED>
> 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
> present.
> 
> 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.
> 
> Cheers,
> Alain
> 
> On Fri, Mar 25, 2011 at 1:58 AM, Ulf Angermann
> <uangermann@REDACTED> 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 <alain.odea@REDACTED>
> >>
> >> Hi Ulf:
> >>
> >> On 2011-03-24, at 5:45, u a <uaforum1@REDACTED> 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
> >
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110326/d42842eb/attachment.htm>


More information about the erlang-questions mailing list