diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-07-29 09:18:16 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-07-29 09:18:16 +0300 |
commit | 3b6a737cd2fb7a523dd63109f86c88b2996cdc3a (patch) | |
tree | aab050fd85e76aea0e869d64cbc5fc801198715f /doc/vmod-dbrw.3 | |
parent | 4912a0408aa773dc80e84e19d0d437795acfa043 (diff) | |
download | vmod-dbrw-3b6a737cd2fb7a523dd63109f86c88b2996cdc3a.tar.gz vmod-dbrw-3b6a737cd2fb7a523dd63109f86c88b2996cdc3a.tar.bz2 |
Use EX/EE for examples in the manpage.
Diffstat (limited to 'doc/vmod-dbrw.3')
-rw-r--r-- | doc/vmod-dbrw.3 | 62 |
1 files changed, 25 insertions, 37 deletions
diff --git a/doc/vmod-dbrw.3 b/doc/vmod-dbrw.3 index 9496270..756fe76 100644 --- a/doc/vmod-dbrw.3 +++ b/doc/vmod-dbrw.3 @@ -13,14 +13,14 @@ .\" .\" You should have received a copy of the GNU General Public License .\" along with vmod-dbrw. If not, see <http://www.gnu.org/licenses/>. -.TH VMOD_DBRW 1 "July 27, 2013" "VMOD_DBRW" "User Reference" +.TH VMOD-DBRW 1 "July 27, 2013" "VMOD-DBRW" "User Reference" .SH NAME vmod-dbrw \- Database-driven rewrite rules for Varnish Cache .SH SYNOPSIS .B import dbrw; -.br +.PP .BI "VOID dbrw.config(STRING " dbtype ", STRING " params ", STRING " query ");" -.br +.PP .BI "STRING dbrw.rewrite(STRING " args ");" .SH DESCRIPTION .B Vmod-dbrw @@ -49,7 +49,7 @@ and semicolon. If any of these have to appear in it, they must either be escaped by prepending them with a backslash, or entire \fIVALUE\fR enclosed in a pair of (single or double) quotes. The following \fBescape sequences\fR are allowed for use in \fIVALUE\fR: -.sp +.PP .nf .ta 8n 18n 42n .ul @@ -177,22 +177,19 @@ This example shows how to implement apache-style permanent redirects in Varnish. .PP The following table is used to keep the redirection data: -.sp -.nf -.in +2 +.PP +.EX CREATE TABLE redirects ( host varchar(255) NOT NULL DEFAULT '', url varchar(255) NOT NULL DEFAULT '', dest varchar(255) DEFAULT NULL, PRIMARY KEY (host,url) ); -.in -.fi +.EE .PP VCL code: -.sp -.nf -.in +2 +.PP +.EX sub vcl_init { dbrw.config("mysql", "database=dbname;user=varnish", {"SELECT dest @@ -217,17 +214,15 @@ sub vcl_error { return (deliver); } } -.in -.fi +.EE .PP Notice the use of concatenation to build the argument to \fBdbrw.rewrite\fR. -.SS Rewrites. +.SS Rewrites .PP The database structure is as follows: -.sp -.nf -.in +2 +.PP +.EX CREATE TABLE rewrite ( host varchar(255) NOT NULL DEFAULT '', url varchar(255) NOT NULL DEFAULT '', @@ -237,14 +232,12 @@ CREATE TABLE rewrite ( flags char(64) DEFAULT NULL, KEY source (host,url) ) -.in -.fi +.EE .PP VCL code: -.sp -.nf -.in +2 -import std; # The std module is used by \fBvcl_error\fR below +.PP +.EX +import std; import dbrw; sub vcl_init { @@ -263,17 +256,15 @@ sub vcl_recv { error(750, "Redirect"); } } -.in -.fi +.EE .PP The \fBvcl_error\fR function uses the \fBX\-VMOD\-DBRW\-Status\fR header, which may be set by \fBredirect=\fR flag in the \fBflags\fR column. Its value is converted to integer using the \fBinteger\fR function from the \fBstd\fR module. If the header is not set, permanent redirect is assumed: -.sp -.nf -.in +2 +.PP +.EX sub vcl_error { if (obj.status == 750) { set obj.http.Location = req.http.X-Redirect-To; @@ -281,8 +272,7 @@ sub vcl_error { return (deliver); } } -.in -.fi +.EE .SS Use of vmod-dbrw and vmod-redirect .PP .ie "\*[.T]"html" \{\ @@ -294,9 +284,8 @@ Using the \fBvmod-redirect\fR module .BR ( https://www.varnish-cache.org/vmod/redirect ) \} you can get rid of the \fBvcl_error\fR subroutine: -.sp -.nf -.in +2 +.PP +.EX import std; import dbrw; import redirect; @@ -311,8 +300,7 @@ sub vcl_recv { req.http.X-Redirect-To), "Redirection"); } } -.in -.fi +.EE .\" The MANCGI variable is set by man.cgi script on Ulysses. .\" The download.inc file contains the default DOWNLOAD section .\" for man-based doc pages. @@ -340,7 +328,7 @@ manual. If the program and .B vmod-dbrw module are properly installed at your site, the command -.sp +.PP .nf .in +4 .B info vmod-dbrw |