summaryrefslogtreecommitdiff
path: root/pod/ngx_devel_kit-0.3.3/ngx_devel_kit-0.3.3.pod
blob: 62e15a69204dbecb83817d48ebb27a8bc03fe876 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
=encoding utf-8


=head1 Name

Nginx Development Kit (NDK)


=head1 Synopsis

The NDK is an Nginx module that is designed to extend the core functionality of the
excellent Nginx webserver in a way that can be used as a basis of other Nginx modules.

It has functions and macros to deal with generic tasks that don't currently have
generic code as part of the core distribution.  The NDK itself adds few features
that are seen from a user's point of view - it's just designed to help reduce the
code that Nginx module developers need to write.

Nginx module developers wishing to use any of the features in the NDK should specify
that the NDK is a dependency of their module, and that users will need to compile
it as well when they compile their own modules.  They will also need to declare in
their own modules which features of the NDK they wish to use (explained below).

If you are not an Nginx module developer, then the only useful part of this project
will be the 'usage for users' section below.




=head1 Status

The NDK is now considered to be stable. It is already being used in quite a few third
party modules (see list below).




=head1 Features


=over


=item *

additional conf_set functions for regexes, complex/script values, paths...

=item *

macros to simplify tasks like checking for NULL values when doing ngx_array_push

=item *

patches to the main source code

=item *

ngx_auto_lib_core generic external library handler is included (see separate readme)


=back




=head1 Design


=head2 modular

The kit itself is designed in a modular way, so that only the required code is compiled.
It's possible to add just a single NDK module, a few or all of them.




=head2 auto-generated & easily extensible

Many of the macros available in the NDK are auto-generated from simple configuration
files.  This makes creating similar macros for your own code very simple - it's usually
just the case of adding an extra line to a config file and re-running the build script.




=head1 Usage for users

If another Nginx module you wish to use specifies that the NDK is a dependency, you
will need to do the following :


=over


=item 1.

download the source (https://github.com/simpl/ngx_devel_kit)

=item 2.

unpack the source (tar -xzf $name)

=item 3.

compile Nginx with the following extra option C<--add-module=/path/to/ngx_devel_kit>.


=back

e.g.


    ./configure --add-module=/path/to/ngx_devel_kit \
                --add-module=/path/to/another/module




=head2 Building as a dynamic module

Starting from NGINX 1.9.11, you can also compile this module as a dynamic module, by using the C<--add-dynamic-module=PATH> option instead of C<--add-module=PATH> on the
C<./configure> command line above. And then you can explicitly load the module in your C<nginx.conf> via the L<load_module|http://nginx.org/en/docs/ngx_core_module.html#load_module>
directive, for example,


    load_module /path/to/modules/ndk_http_module.so;
    load_module /path/to/another/module.so;




=head1 Usage for developers

To use the NDK in your own module, you need to add the following:


=over


=item 1.

add this line to your module


=back


    #include    <ndk.h>

Note: since the NDK includes the following lines


    #include    <ngx_config.h>
    #include    <ngx_core.h>
    #include    <ngx_http.h>

you can replace these with the single include above.

=over


=item 1.

add the following line in the config file for your module:


=back


    have=NDK_[module_name]  . auto/have

for each NDK module that you wish to use (you need to include auto/have multiple
times if you wish to use multiple NDK modules.

Note: the old method of setting


    CFLAGS="$CFLAGS -DNDK_[module_name]"

is now deprecated. It will still work, but results in unnecessary lines being
displayed when compiling Nginx.




=head2 Warning: Using NDK_ALL

You can also set C<NDK_ALL> to include all the NDK modules.  This is primarily as
a convenience in the early stages of development of another module. However,

DO NOT LEAVE C<NDK_ALL> IN YOUR CONFIG FILE WHEN PUBLISHING

Although the NDK is fairly small now, it could in time become a large repository
of code that would, if using NDK_ALL, result in considerably more code being compiled
than is necessary.




=head1 Modules using NDK

The following 3rd-party modules make use of NDK.


=over


=item *

L<ngx_http_lua_module|https://github.com/openresty/lua-nginx-module#readme>

=item *

L<ngx_http_set_misc_module|https://github.com/openresty/set-misc-nginx-module#readme>

=item *

L<ngx_http_encrypted_session_module|https://github.com/openresty/encrypted-session-nginx-module#readme>

=item *

L<ngx_http_form_input_module|https://github.com/calio/form-input-nginx-module#readme>

=item *

L<ngx_http_iconv_module|https://github.com/calio/iconv-nginx-module#readme>

=item *

L<ngx_http_array_var_module|https://github.com/openresty/array-var-nginx-module#readme>


=back

If you would like to add your module to this list, please let us know.




=head1 TODO


=over


=item *

documentation for modules that don't already have it

=item *

additional phase-handler functions

=item *

generically testing for needing to add a handler

=item *

remove dependency of set_var on OpenSSL being compiled in

=item *

for backward compatability, add the ndk_macros


=back




=head1 License

Copyright (c) 2010-2018, Marcus Clyne

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:


=over


=item 1.

Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.

=item 2.

Redistributions in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.

=item 3.

Neither the name of the copyright holder nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior
written permission.


=back

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.




=head1 Contributing / Feedback

If you are an Nginx module developer, and have developed some functions that are
generic in nature (or would be easily adapted to be so), then please send them to
me at the address below, and I'll addmclyne to the kit.




=head1 Author

L<Marcus Clyne|https://github.com/mclyne>




=head1 Special Thanks

A special thanks goes to L<Yichun Zhang|https://github.com/agentzh> for helping to maintain
this module.