1docs::api::Apache2::ModUusleer(3C)ontributed Perl Documednotcast:i:oanpi::Apache2::Module(3)
2
3
4

NAME

6       Apache2::Module - Perl API for creating and working with Apache modules
7

Synopsis

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

Description

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

API

59       "Apache2::Module" provides the following functions and/or methods:
60
61   "add"
62       Add a module's custom configuration directive to Apache.
63
64         Apache2::Module::add($package, $cmds);
65
66       arg1: $package ( string )
67           the package of the module to add
68
69       arg2: $cmds ( ARRAY of HASH refs )
70           the list of configuration directives to add
71
72       ret: no return value
73       since: 2.0.00
74
75       See also Apache Server Configuration Customization in Perl.
76
77   "ap_api_major_version"
78       Get the httpd API version this module was build against, not the
79       module's version.
80
81         $major_version = $module->ap_api_major_version();
82
83       obj: $module ( "Apache2::Module object" )
84       ret: $major_version ( integer )
85       since: 2.0.00
86
87       This methid is used to check that module is compatible with this
88       version of the server before loading it.
89
90   "ap_api_minor_version"
91       Get the module API minor version.
92
93         $minor_version = $module->ap_api_minor_version();
94
95       obj: $module ( "Apache2::Module object" )
96       ret: $minor_version ( integer )
97       since: 2.0.00
98
99       "ap_api_minor_version()" provides API feature milestones.
100
101       It's not checked during module init.
102
103   "cmds"
104       Get the "Apache2::Command" object, describing all of the directives
105       this module defines.
106
107         $command = $module->cmds();
108
109       obj: $module ( "Apache2::Module object" )
110       ret: $command ( "Apache2::Command object" )
111       since: 2.0.00
112
113   "get_config"
114       Retrieve a module's configuration. Used by configuration directives.
115
116         $cfg = Apache2::Module::get_config($class, $server, $dir_config);
117         $cfg = Apache2::Module::get_config($class, $server);
118         $cfg =          $self->get_config($server, $dir_config);
119         $cfg =          $self->get_config($server);
120
121       obj: $module ( "Apache2::Module object" )
122       arg1: $class ( string )
123           The Perl package this configuration is for
124
125       arg2: $server ( "Apache2::ServerRec object" )
126           The current server, typically "$r->server" or "$parms->server".
127
128       opt arg3: $dir_config ( "Apache2::ConfVector object" )
129           By default, the configuration returned is the server level one. To
130           retrieve the per directory configuration, use "$r->per_dir_config"
131           as a last argument.
132
133       ret: $cfg (HASH reference)
134           A reference to the hash holding the module configuration data.
135
136       since: 2.0.00
137
138       See also Apache Server Configuration Customization in Perl.
139
140   "find_linked_module"
141       Find a module based on the name of the module
142
143         $module = Apache2::Module::find_linked_module($name);
144
145       arg1: $name ( string )
146           The name of the module ending in ".c"
147
148       ret: $module ( "Apache2::Module object" )
149           The module object if found, "undef" otherwise.
150
151       since: 2.0.00
152
153       For example:
154
155         my $module = Apache2::Module::find_linked_module('mod_ssl.c');
156
157   "loaded"
158       Determine if a certain module is loaded
159
160         $loaded = Apache2::Module::loaded($module);
161
162       name: $module ( string )
163           The name of the module to search for.
164
165           If $module ends with ".c", search all the modules, statically
166           compiled and dynamically loaded.
167
168           If $module ends with ".so", search only the dynamically loaded
169           modules.
170
171           If $module doesn't contain a ".", search the loaded Perl modules
172           (checks %INC).
173
174       ret: $loaded ( boolean )
175           Returns true if the module is loaded, false otherwise.
176
177       since: 2.0.00
178
179       For example, to test if this server supports ssl:
180
181         if (Apache2::Module::loaded('mod_ssl.c')) {
182             [...]
183         }
184
185       To test is this server dynamically loaded mod_perl:
186
187         if (Apache2::Module::loaded('mod_perl.so')) {
188             [...]
189         }
190
191       To test if "Apache2::Status" is loaded:
192
193         if (Apache2::Module::loaded('Apache2::Status')) {
194             [...]
195         }
196
197   "module_index"
198       Get the index to this modules structures in config vectors.
199
200         $index = $module->module_index();
201
202       obj: $module ( "Apache2::Module object" )
203       ret: $index ( integer )
204       since: 2.0.00
205
206   "name"
207       Get the name of the module's .c file
208
209         $name = $module->name();
210
211       obj: $module ( "Apache2::Module object" )
212       ret: $name ( string )
213       since: 2.0.00
214
215       For example a mod_perl module, will return: mod_perl.c.
216
217   "next"
218       Get the next module in the list, "undef" if this is the last module in
219       the list.
220
221         $next_module = $module->next();
222
223       obj: $module ( "Apache2::Module object" )
224       ret: $next_module ( "Apache2::Module object" )
225       since: 2.0.00
226
227   "remove_loaded_module"
228       Remove a module from the list of loaded modules permanently.
229
230         $module->remove_loaded_module();
231
232       obj: $module ( "Apache2::Module object" )
233       ret: no return value
234       since: 2.0.00
235
236   "top_module"
237       Returns the first module in the module list. Usefull to start a module
238       iteration.
239
240         $module = Apache2::Module::top_module();
241
242       ret: $module ( "Apache2::Module object" )
243       since: 2.0.00
244

See Also

246       mod_perl 2.0 documentation.
247
249       mod_perl 2.0 and its core modules are copyrighted under The Apache
250       Software License, Version 2.0.
251

Authors

253       The mod_perl development team and numerous contributors.
254
255
256
257perl v5.32.1                      2021-01-26     docs::api::Apache2::Module(3)
Impressum