Skip to content

Commit 61acd28

Browse files
committed
Revproxy: removing deprecated (and ambiguous) regexp option
1 parent be8b0fe commit 61acd28

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

src/extensions/revproxy.ml

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@ let section = Lwt_log.Section.make "ocsigen:ext:revproxy"
2929

3030
type redirection =
3131
{ regexp : Pcre.regexp
32-
; full_url : [`Maybe | `No | `Yes]
32+
; full_url : bool
3333
; dest : string
3434
; pipeline : bool
3535
; keephost : bool }
3636
(** The table of redirections for each virtual server *)
3737

38-
let create_redirection ?(full_url = `Yes) ?(pipeline = true) ?(keephost = false)
38+
let create_redirection ?(full_url = true) ?(pipeline = true) ?(keephost = false)
3939
~regexp dest
4040
=
41-
let full_url = (full_url :> [`Maybe | `No | `Yes]) in
4241
let regexp = Pcre.regexp ("^" ^ regexp ^ "$") in
4342
{regexp; dest; full_url; pipeline; keephost}
4443

@@ -53,15 +52,8 @@ let gen dir = function
5352
(fun () ->
5453
Lwt_log.ign_info ~section "Is it a redirection?";
5554
let dest =
56-
let fi full =
57-
Ocsigen_extensions.find_redirection dir.regexp full dir.dest
58-
request_info
59-
in
60-
match dir.full_url with
61-
| `Yes -> fi true
62-
| `No -> fi false
63-
| `Maybe -> (
64-
try fi false with Ocsigen_extensions.Not_concerned -> fi true)
55+
Ocsigen_extensions.find_redirection dir.regexp dir.full_url
56+
dir.dest request_info
6557
in
6658
let https, host, port, path =
6759
try
@@ -148,7 +140,7 @@ let gen dir = function
148140

149141
let parse_config config_elem =
150142
let regexp = ref None in
151-
let full_url = ref `Yes in
143+
let full_url = ref true in
152144
let dest = ref None in
153145
let pipeline = ref true in
154146
let keephost = ref false in
@@ -158,15 +150,12 @@ let parse_config config_elem =
158150
~elements:
159151
[ Configuration.element ~name:"revproxy"
160152
~attributes:
161-
[ Configuration.attribute ~name:"regexp" (fun s ->
153+
[ Configuration.attribute ~name:"fullurl" (fun s ->
162154
regexp := Some s;
163-
full_url := `Yes)
164-
; Configuration.attribute ~name:"fullurl" (fun s ->
165-
regexp := Some s;
166-
full_url := `Yes)
155+
full_url := true)
167156
; Configuration.attribute ~name:"suburl" (fun s ->
168157
regexp := Some s;
169-
full_url := `No)
158+
full_url := false)
170159
; Configuration.attribute ~name:"dest" (fun s -> dest := Some s)
171160
; Configuration.attribute ~name:"keephost" (function
172161
| "keephost" -> keephost := true

src/extensions/revproxy.mli

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
11
(** Revproxy: Forward a request to another Web server *)
22

3-
(** If you want to use this extension with Ocsigen Server's configuration file,
4-
+ have a look at the {% <<a_manual chapter="revproxy"|manual page>>%}.
5-
+ If you are using Ocsigen Server as a library, use the interface described
6-
+ here. Each of these functions behaves exactly as its configuration file
7-
counterpart.
8-
+*)
3+
(** If you want to use this extension with Ocsigen Server's configuration file,
4+
have a look at the {% <<a_manual chapter="revproxy"|manual page>>%}.
5+
If you are using Ocsigen Server as a library, use the interface described
6+
here. Each of these functions behaves exactly as its configuration file
7+
counterpart.
8+
*)
99

1010
(**
1111
This module belongs to ocamlfind package
1212
[ocsigenserver.ext.revproxy].
1313
*)
1414

15+
(** Example of use:
16+
{[
17+
let _ =
18+
Ocsigen_server.start
19+
[ Ocsigen_server.host ~regexp:".*"
20+
[ Ocsigen_server.site ["blah"]
21+
[ Revproxy.run
22+
~redirection:(Revproxy.create_redirection ) ]]]
23+
]}
24+
*)
25+
1526
val section : Lwt_log_core.section
1627
(** use Lwt_log.Section.set_level in order to set the log level *)
1728

1829
type redirection
1930

2031
val create_redirection :
21-
?full_url:[< `Maybe | `No | `Yes > `Yes]
32+
?full_url:bool
2233
-> ?pipeline:bool
2334
-> ?keephost:bool
2435
-> regexp:string

0 commit comments

Comments
 (0)