|
| 1 | +============ |
| 2 | +vmod_example |
| 3 | +============ |
| 4 | + |
| 5 | +---------------------- |
| 6 | +Varnish Example Module |
| 7 | +---------------------- |
| 8 | + |
| 9 | +:Author: Martin Blix Grydeland |
| 10 | +:Date: 2011-05-26 |
| 11 | +:Version: 1.0 |
| 12 | +:Manual section: 3 |
| 13 | + |
| 14 | +SYNOPSIS |
| 15 | +======== |
| 16 | + |
| 17 | +import example; |
| 18 | + |
| 19 | +DESCRIPTION |
| 20 | +=========== |
| 21 | + |
| 22 | +Example Varnish vmod demonstrating how to write an out-of-tree Varnish vmod. |
| 23 | + |
| 24 | +Implements the traditional Hello World as a vmod. |
| 25 | + |
| 26 | +FUNCTIONS |
| 27 | +========= |
| 28 | + |
| 29 | +hello |
| 30 | +----- |
| 31 | + |
| 32 | +Prototype |
| 33 | + :: |
| 34 | + |
| 35 | + hello(STRING S) |
| 36 | +Return value |
| 37 | + STRING |
| 38 | +Description |
| 39 | + Returns "Hello, " prepended to S |
| 40 | +Example |
| 41 | + :: |
| 42 | + |
| 43 | + set resp.http.hello = example.hello("World"); |
| 44 | + |
| 45 | +INSTALLATION |
| 46 | +============ |
| 47 | + |
| 48 | +This is an example skeleton for developing out-of-tree Varnish |
| 49 | +vmods. It implements the "Hello, World!" as a vmod callback. Not |
| 50 | +particularly useful in good hello world tradition, but demonstrates how |
| 51 | +to get the glue around a vmod working. |
| 52 | + |
| 53 | +The source tree is based on autotools to configure the building, and |
| 54 | +does also have the necessary bits in place to do functional unit tests |
| 55 | +using the varnishtest tool. |
| 56 | + |
| 57 | +Usage:: |
| 58 | + |
| 59 | + ./configure VARNISHSRC=DIR [VMODDIR=DIR] |
| 60 | + |
| 61 | +`VARNISHSRC` is the directory of the Varnish source tree for which to |
| 62 | +compile your vmod. Both the `VARNISHSRC` and `VARNISHSRC/include` |
| 63 | +will be added to the include search paths for your module. |
| 64 | + |
| 65 | +Optionally you can also set the vmod install directory by adding |
| 66 | +`VMODDIR=DIR` (defaults to the pkg-config discovered directory from your |
| 67 | +Varnish installation). |
| 68 | + |
| 69 | +Make targets: |
| 70 | + |
| 71 | +* make - builds the vmod |
| 72 | +* make install - installs your vmod in `VMODDIR` |
| 73 | +* make check - runs the unit tests in ``src/tests/*.vtc`` |
| 74 | + |
| 75 | +In your VCL you could then use this vmod along the following lines:: |
| 76 | + |
| 77 | + import example; |
| 78 | + |
| 79 | + sub vcl_deliver { |
| 80 | + # This sets resp.http.hello to "Hello, World" |
| 81 | + set resp.http.hello = example.hello("World"); |
| 82 | + } |
| 83 | + |
| 84 | +HISTORY |
| 85 | +======= |
| 86 | + |
| 87 | +This manual page was released as part of the libvmod-example package, |
| 88 | +demonstrating how to create an out-of-tree Varnish vmod. |
| 89 | + |
| 90 | +COPYRIGHT |
| 91 | +========= |
| 92 | + |
| 93 | +This document is licensed under the same license as the |
| 94 | +libvmod-example project. See LICENSE for details. |
| 95 | + |
| 96 | +* Copyright (c) 2011 Varnish Software |
0 commit comments