[prev in list] [next in list] [prev in thread] [next in thread] List: apache-modperl Subject: Custom Configuration Best Practice From: "David E. Wheeler" <david () justatheory ! com> Date: 2015-03-02 1:05:22 Message-ID: 6BB89131-CFEA-4D8F-BD68-5225A3B398EA () justatheory ! com [Download RAW message or body] Fellow mod_perlers, I followed the instructions in the Server Configuration Customization guide to create \ a custom Apache configuration directive like so: my $foo; sub foo { $foo = $_[2] } Apache2::Module::add(__PACKAGE__, [ { name => 'MyFoo', func => __PACKAGE__ . '::foo' }, ]); sub handler { my $r = shift; $r->print($foo); return OK; } This works pretty well; I can now set the MyFoo directive in my httpd.conf. But it \ feels a little hinky to set up package globals that get set on every request like \ this. It feels like it would make more sense if they were getting passed to an object \ method, but foo() is called as a function here; the first parameter is the class \ name, not an object. Also, I tried to use an anonymous sub in the add call: my $foo; Apache2::Module::add(__PACKAGE__, [ { name => 'MyFoo', func => sub { $foo = $_[2] }, ]); But that didn't work either; mod_perl complained that it couldn't find a function \ named "CODE(0x1d5e988P)" in the package. I was surprised by this since the docs say: > The func attribute expects a reference to a function or a function name. https://perl.apache.org/docs/2.0/user/config/custom.html#C_func_ So none of this feels quite right to me. Anyone got a point to best practices for \ setting up custom configuration directives? Or is this close to what everyone does \ anyway? Thanks, David ["smime.p7s" (smime.p7s)] 0 *H 010 + 0 *H i0-0 0 *H 010 UIL10U StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 \ Primary Intermediate Client CA0 140905115440Z 150906110220Z0F10Udavid@justatheory.com1$0" *H david@justatheory.com0"0 *H 0 2 ?}^#4F&eR(szI0%Ado%j-"Zp4f*?-IAӈdyDi ?wJCR2uu >Aצ WX~S=jzj7ϣFiﱅK"{^6s wEoWpnQC5 \ gĬ]Oo o@P2vʎ՞`!Ey<tDei>(uz_Ʋ0yv/ \ 00 U0 0U0U%0++0U[k3{ף<>0U#0Sr풜\|~5NԸQ0 \ U0david@justatheory.com0LU \ C0?0;+70*0.+"http://www.startssl.com/policy.pdf0+00' \ StartCom Certification Authority0This certificate was issued according to the \ Class 1 Validation requirements of the StartCom CA policy, reliance only for the \ intended purpose in compliance of the relying party obligations.06U/0-0+ ) \ '%http://crl.startssl.com/crtu1-crl.crl0+009+0-http://ocsp.st \ artssl.com/sub/class1/client/ca0B+06http://aia.startssl.com/certs/sub.class1.client.ca.crt0#U0http://www.startssl.com/0 *H 2lTb *ZJR*L)Tu IԓcrblK .ثkk* ZLtASJU֚n \ @0̉[#YgXq}Y@WpwKpXjB~C鲨GJKI*[(to ˨:90NW$ld!oğ{B[PƉ ',?TͮQV ДC[cKjb \ gpf|V040 0 *H 0}10 UIL10U StartCom Ltd.1+0)U"Secure Digital Certificate Signing1)0'U StartCom \ Certification Authority0 071024210155Z 171024210155Z010 UIL10U StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 \ Primary Intermediate Client CA0"0 *H 0 -).2AUGo#G B|NDRpM-B=o-we5JQpa>O.# ._<V [~**pz~3WG .ᘟMlr[<Ce6fqO"uxfWN#uic \ gkv$Lb%y`_{`xK'GN 00U00U \ 0USr풜\|~5NԸQ0U#0N@[i04hCA0f+ \ Z0X0'+0http://ocsp.startssl.com/ca0-+0!http://www.startssl.com/sfsca.crt0[UT0R0' \ % #!http://www.startssl.com/sfsca.crl0' % \ #!http://crl.startssl.com/sfsca.crl0U \ y0w0u+70f0.+"http://www.startssl.com/policy.pdf04+(http://www.startssl.com/intermediate.pdf0 *H }x,\c^#wMq}>UK/^yX֏y \ frMIŲB61ymQҨݬZ0&