diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-12-08 12:03:40 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-12-08 12:03:40 +0200 |
commit | 602f4d93070ac0e762e0cbe3ef72ba792f9c4811 (patch) | |
tree | 8047168c6b23de38973b494b6ec794a81faf3576 /doc/vmod-dbrw.3 | |
parent | 2a684f1cdd7723c2ded277ea2c7e66227b6f3ae1 (diff) | |
download | vmod-dbrw-602f4d93070ac0e762e0cbe3ef72ba792f9c4811.tar.gz vmod-dbrw-602f4d93070ac0e762e0cbe3ef72ba792f9c4811.tar.bz2 |
Implement the $(urlprefixes) built-in function.
* NEWS: Update.
* README: Update.
* configure.ac: Version 2.2.91
* doc/vmod-dbrw.3: Document the use of $(urlprefixes) built-in
* doc/vmod-dbrw.texi: Likewise.
* src/vmod_dbrw.c (parse_flags): Make sure status string is null-terminated.
(do_rewrite): Expand built-in functions in $(). Support urlprefixes.
On debug_level=100, produce detailed trace of expansions.
* src/wordsplit.c: Pull from grecs commit 9097d529.
* src/wordsplit.h: Likewise.
* tests/initdb.at (rewrite): Change the url column.
* tests/rewrite01.at: Use $(urlprefixes) in the SQL templates.
* tests/rewrite02.at: Likewise.
* tests/rewrite03.at: Likewise.
* tests/rewrite04.at: Likewise.
* tests/rewrite05.at: Likewise.
* tests/rewrite06.at: Likewise.
Diffstat (limited to 'doc/vmod-dbrw.3')
-rw-r--r-- | doc/vmod-dbrw.3 | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/doc/vmod-dbrw.3 b/doc/vmod-dbrw.3 index 6f1dba8..4760b6b 100644 --- a/doc/vmod-dbrw.3 +++ b/doc/vmod-dbrw.3 @@ -1,5 +1,5 @@ .\" This file is part of Vmod-dbrw -*- nroff -*- -.\" Copyright (C) 2013-2017 Sergey Poznyakoff +.\" Copyright (C) 2013-2018 Sergey Poznyakoff .\" .\" Vmod-dbrw is free software; you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ .\" .\" 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 "January 30, 2018" "VMOD-DBRW" "User Reference" +.TH VMOD-DBRW 1 "December 8, 2018" "VMOD-DBRW" "User Reference" .SH NAME vmod-dbrw \- Database-driven rewrite rules for Varnish Cache .SH SYNOPSIS @@ -134,6 +134,32 @@ form can be used in contexts where the variable name is immediately followed by another letter, to prevent it from being counted as a part of the name. .PP +The special construct +.sp +.EX +$(urlprefixes \fIPATH\fR) +.EE +.sp +expands to a comma-separated list of all possible path prefixes in +\fIPATH\fR. Each element in the list is quoted, so the result can +safely be used in SQL statements. For example, +.sp +.EX +$(urlprefixes "/local/user/login") +.EE +.sp +produces +.sp +.EX + '/local/user/login','/local/user','/local' +.EE +.PP +This statement is usually used in \fBIN\fR SQL constructs, e.g. +.sp +.EX +SELECT * FROM table WHERE url IN ($(urlprefixes $url)) +.EE +.PP The expanded query is then sent to the database server. Handling of the return value depends on the number of fields it contains. .SS Strict matches @@ -248,7 +274,9 @@ sub vcl_recv { # wildcard pattern. dbrw.config("mysql", "database=varnish;user=varnish;debug=10", {"SELECT dest,pattern,value,flags FROM rewrite - WHERE host='$host' and '$url' like url"}); + WHERE host='$host' + AND url IN ($(urlprefixes $url)) + ORDER BY LENGTH(dest),value DESC"}); set req.http.X-Redirect-To = dbrw.rewrite("host=" + req.http.Host + ";" + "url=" + req.url); |