1docs::api::Apache2::ModUusleer(3C)ontributed Perl Documednotcast:i:oanpi::Apache2::Module(3)
2
3
4
6 Apache2::Module - Perl API for creating and working with Apache modules
7
9 use Apache2::Module ();
10
11 #Define a configuration directive
12 my @directives = (
13 {
14 name => 'MyDirective',
15 }
16 );
17
18 Apache2::Module::add(__PACKAGE__, \@directives);
19
20 # iterate over the whole module list
21 for (my $modp = Apache2::Module::top_module(); $modp; $modp = $modp->next) {
22 my $name = $modp->name;
23 my $index = $modp->module_index;
24 my $ap_api_major_version = $modp->ap_api_major_version;
25 my $ap_api_minor_version = $modp->ap_api_minor_version;
26 my $commands = $modp->cmds;
27 }
28
29 # find a specific module
30 my $module = Apache2::Module::find_linked_module('mod_ssl.c');
31
32 # remove a specific module
33 $module->remove_loaded_module();
34
35 # access module configuration from a directive
36 sub MyDirective {
37 my ($self, $parms, $args) = @_;
38 my $srv_cfg = Apache2::Module::get_config($self, $parms->server);
39 [...]
40 }
41
42 # test if an Apache module is loaded
43 if (Apache2::Module::loaded('mod_ssl.c')) {
44 [...]
45 }
46
47 # test if a Perl module is loaded
48 if (Apache2::Module::loaded('Apache2::Status')) {
49 [...]
50 }
51
53 "Apache2::Module" provides the Perl API for creating and working with
54 Apache modules
55
56 See Apache Server Configuration Customization in Perl.
57
59 "Apache2::Module" provides the following functions and/or methods:
60
61 "add"
62
63 Add a module's custom configuration directive to Apache.
64
65 Apache2::Module::add($package, $cmds);
66
67 arg1: $package ( string )
68 the package of the module to add
69
70 arg2: $cmds ( ARRAY of HASH refs )
71 the list of configuration directives to add
72
73 ret: no return value
74 since: 2.0.00
75
76 See also Apache Server Configuration Customization in Perl.
77
78 "ap_api_major_version"
79
80 Get the httpd API version this module was build against, not the mod‐
81 ule's version.
82
83 $major_version = $module->ap_api_major_version();
84
85 obj: $module ( "Apache2::Module object" )
86 ret: $major_version ( integer )
87 since: 2.0.00
88
89 This methid is used to check that module is compatible with this ver‐
90 sion of the server before loading it.
91
92 "ap_api_minor_version"
93
94 Get the module API minor version.
95
96 $minor_version = $module->ap_api_minor_version();
97
98 obj: $module ( "Apache2::Module object" )
99 ret: $minor_version ( integer )
100 since: 2.0.00
101
102 "ap_api_minor_version()" provides API feature milestones.
103
104 It's not checked during module init.
105
106 "cmds"
107
108 Get the "Apache2::Command" object, describing all of the directives
109 this module defines.
110
111 $command = $module->cmds();
112
113 obj: $module ( "Apache2::Module object" )
114 ret: $command ( "Apache2::Command object" )
115 since: 2.0.00
116
117 "get_config"
118
119 Retrieve a module's configuration. Used by configuration directives.
120
121 $cfg = Apache2::Module::get_config($class, $server, $dir_config);
122 $cfg = Apache2::Module::get_config($class, $server);
123 $cfg = $self->get_config($server, $dir_config);
124 $cfg = $self->get_config($server);
125
126 obj: $module ( "Apache2::Module object" )
127 arg1: $class ( string )
128 The Perl package this configuration is for
129
130 arg2: $server ( "Apache2::ServerRec object" )
131 The current server, typically "$r->server" or "$parms->server".
132
133 opt arg3: $dir_config ( "Apache2::ConfVector object" )
134 By default, the configuration returned is the server level one. To
135 retrieve the per directory configuration, use "$r->per_dir_config"
136 as a last argument.
137
138 ret: $cfg (HASH reference)
139 A reference to the hash holding the module configuration data.
140
141 since: 2.0.00
142
143 See also Apache Server Configuration Customization in Perl.
144
145 "find_linked_module"
146
147 Find a module based on the name of the module
148
149 $module = Apache2::Module::find_linked_module($name);
150
151 arg1: $name ( string )
152 The name of the module ending in ".c"
153
154 ret: $module ( "Apache2::Module object" )
155 The module object if found, "undef" otherwise.
156
157 since: 2.0.00
158
159 For example:
160
161 my $module = Apache2::Module::find_linked_module('mod_ssl.c');
162
163 "loaded"
164
165 Determine if a certain module is loaded
166
167 $loaded = Apache2::Module::loaded($module);
168
169 name: $module ( string )
170 The name of the module to search for.
171
172 If $module ends with ".c", search all the modules, statically com‐
173 piled and dynamically loaded.
174
175 If $module ends with ".so", search only the dynamically loaded mod‐
176 ules.
177
178 If $module doesn't contain a ".", search the loaded Perl modules
179 (checks %INC).
180
181 ret: $loaded ( boolean )
182 Returns true if the module is loaded, false otherwise.
183
184 since: 2.0.00
185
186 For example, to test if this server supports ssl:
187
188 if (Apache2::Module::loaded('mod_ssl.c')) {
189 [...]
190 }
191
192 To test is this server dynamically loaded mod_perl:
193
194 if (Apache2::Module::loaded('mod_perl.so')) {
195 [...]
196 }
197
198 To test if "Apache2::Status" is loaded:
199
200 if (Apache2::Module::loaded('Apache2::Status')) {
201 [...]
202 }
203
204 "module_index"
205
206 Get the index to this modules structures in config vectors.
207
208 $index = $module->module_index();
209
210 obj: $module ( "Apache2::Module object" )
211 ret: $index ( integer )
212 since: 2.0.00
213
214 "name"
215
216 Get the name of the module's .c file
217
218 $name = $module->name();
219
220 obj: $module ( "Apache2::Module object" )
221 ret: $name ( string )
222 since: 2.0.00
223
224 For example a mod_perl module, will return: mod_perl.c.
225
226 "next"
227
228 Get the next module in the list, "undef" if this is the last module in
229 the list.
230
231 $next_module = $module->next();
232
233 obj: $module ( "Apache2::Module object" )
234 ret: $next_module ( "Apache2::Module object" )
235 since: 2.0.00
236
237 "remove_loaded_module"
238
239 Remove a module from the list of loaded modules permanently.
240
241 $module->remove_loaded_module();
242
243 obj: $module ( "Apache2::Module object" )
244 ret: no return value
245 since: 2.0.00
246
247 "top_module"
248
249 Returns the first module in the module list. Usefull to start a module
250 iteration.
251
252 $module = Apache2::Module::top_module();
253
254 ret: $module ( "Apache2::Module object" )
255 since: 2.0.00
256
258 mod_perl 2.0 documentation.
259
261 mod_perl 2.0 and its core modules are copyrighted under The Apache
262 Software License, Version 2.0.
263
265 The mod_perl development team and numerous contributors.
266
267
268
269perl v5.8.8 2006-11-19 docs::api::Apache2::Module(3)