@@ -6,50 +6,80 @@ vmod_example
66Varnish Example Module
77----------------------
88
9- :Author: Martin Blix Grydeland
10- :Date: 2011-05-26
9+ :Author: Rogier "DocWilco" Mulhuijzen
10+ :Date: 2012-02-15
1111:Version: 1.0
1212:Manual section: 3
1313
1414SYNOPSIS
1515========
1616
17- import example;
17+ ::
18+
19+ import urlcode;
20+ urlcode.encode(<string>);
21+ urlcode.decode(<string>);
1822
1923DESCRIPTION
2024===========
2125
22- Example Varnish vmod demonstrating how to write an out-of-tree Varnish vmod.
26+ Varnish Module (vmod) for encoding or decoding to/from "percent encoding" as
27+ per RFC3986.
2328
24- Implements the traditional Hello World as a vmod .
29+ For backward compatibility, a + will be decoded to a space .
2530
2631FUNCTIONS
2732=========
2833
29- hello
30- -----
34+ Example VCL::
35+
36+ backend foo { ... };
37+
38+ import urlcode;
39+
40+ sub vcl_recv {
41+ set req.url = "/example?url=" + urlcode.encode("http://" +
42+ req.http.host + req.url);
43+ }
44+
45+ encode
46+ ------
3147
3248Prototype
3349 ::
3450
35- hello(STRING S)
51+ urlcode.encode(STRING input)
52+
3653Return value
3754 STRING
3855Description
39- Returns "Hello, " prepended to S
56+ Returns a percent encoded version of input.
4057Example
58+ ::
59+
60+ set resp.http.foo = urlcode.encode("hello world!");
61+
62+ decode
63+ ------
64+
65+ Prototype
4166 ::
4267
43- set resp.http.hello = example.hello("World");
68+ urlcode.decode(STRING input)
69+
70+ Return value
71+ STRING
72+ Description
73+ Returns a percent decoded version of input.
74+ Example
75+ ::
76+
77+ set resp.http.foo = urlcode.decode("hello%20world%21");
78+
4479
4580INSTALLATION
4681============
4782
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-
5383The source tree is based on autotools to configure the building, and
5484does also have the necessary bits in place to do functional unit tests
5585using the varnishtest tool.
@@ -72,25 +102,16 @@ Make targets:
72102* make install - installs your vmod in `VMODDIR `
73103* make check - runs the unit tests in ``src/tests/*.vtc ``
74104
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- }
83105
84106HISTORY
85107=======
86108
87- This manual page was released as part of the libvmod-example package,
88- demonstrating how to create an out-of-tree Varnish vmod.
109+ Version 0.1: Initial version.
89110
90111COPYRIGHT
91112=========
92113
93114This document is licensed under the same license as the
94- libvmod-example project. See LICENSE for details.
115+ libvmod-urlcode project. See LICENSE for details.
95116
96- * Copyright (c) 2011 Varnish Software
117+ * Copyright (c) 2012 Fastly Inc.
0 commit comments