[erlang-questions] Re: how to patch a standard module

Ola Andersson A ola.a.andersson@REDACTED
Fri Jan 14 10:32:05 CET 2011


Hi,

It is actually possible to to what you want. I have used a piece of
code that could replace functions in existing modules by manipulating
the beam code. In that project we only used it in eunit testing to stub
functions in order to isolate the tested code.
I'm not sure about using that method in a production system though.
I don't have the code available any more so I can't provide any details
about it but I think that Tomas Abrahamsson who sometimes contributes to
this list could give some pointers on how to do it if he reads this.
/OLA.


> -----Original Message-----
> From: erlang-questions@REDACTED 
> [mailto:erlang-questions@REDACTED] On Behalf Of Gijsbert
> Sent: den 14 januari 2011 00:47
> To: erlang-questions@REDACTED
> Subject: [erlang-questions] Re: how to patch a standard module
> 
> 
> 
> On Jan 13, 10:25 pm, "Tomasz Maciejewski" <pon...@REDACTED> wrote:
> > Dnia 13-01-2011 o 16:52:23 Gijsbert 
> <gijsbert.de.h...@REDACTED> napisał(a):
> >
> > > Hi,
> >
> > > I'd like to extend httpd_request.erl to handle the OPTIONS method.
> > > I've managed to do this by copying httpd_request.erl into 
> my project 
> > > and making sure it overrides the standard version.
> > > My question: is it possible to redefine a function in a standard 
> > > module at runtime? Then I could define my own 
> validate(Method, Uri,
> > > Version) function (just a few lines) and keep using the standard 
> > > httdp_request.erl.
> >
> > > Regards,
> > > Gijsbert
> >
> > If you like to extend httpd, you should write a module for 
> it, instead of patching original http_request.erl. All the 
> informations are 
> here:http://www.erlang.org/doc/man/httpd.html. You can also 
> see how mod_get.erl and mod_head.erl are done.
> 
> Alas, my module is never called because 
> httpd_request:validate() does not have a clause for "OPTIONS" 
> and returns {error, {not_implemented, ...}}. As far as I know 
> I cannot extend the validation phase of httpd.
> 
> >
> > For redefining function at runtime, you can compile and 
> load modified module by typing "c(module)", or just load new 
> beam by "l(module)".
> >
> > --
> > Tomasz Maciejewski
> >
> > ________________________________________________________________
> > erlang-questions (at) erlang.org mailing list.
> > Seehttp://www.erlang.org/faq.html
> > To unsubscribe; mailto:erlang-questions-unsubscr...@REDACTED
> 
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
> 
> 


More information about the erlang-questions mailing list