Skip to content

Commit 731e32c

Browse files
committed
Extensions: API doc improvements
1 parent 98df03a commit 731e32c

File tree

13 files changed

+173
-42
lines changed

13 files changed

+173
-42
lines changed

doc/indexdoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{1 Ocsigen server - API reference}
2-
2+
{!modules:
3+
Ocsigen_server
4+
}
35
{2 Extensions}
46
{!modules:
57
Staticmod
@@ -29,8 +31,8 @@ Ocsigen_config
2931
{!modules:
3032
Ocsigen_extensions
3133
Ocsigen_local_files
34+
Ocsigen_header
3235
Ocsigen_stream
33-
Authbasic
3436
}
3537

3638
{2 Indexes}

src/extensions/accesscontrol.mli

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@ This module belongs to ocamlfind package
3232
[ocsigenserver.ext.accesscontrol].
3333
*)
3434

35+
(** Example of use (with {% <<a_manual chapter="redirectmod"|Redirectmod>>%}):
36+
{[
37+
let _ =
38+
Ocsigen_server.start
39+
[ Ocsigen_server.host ~regexp:".*"
40+
[ Accesscontrol.(
41+
if_ (not_ ssl)
42+
[ Redirectmod.run
43+
~redirection:
44+
(Redirectmod.create_redirection ~full_url:false
45+
~regexp:"(.* )" "https://yourdomain.org/\\1")
46+
() ]
47+
[ ... ]) ]
48+
]
49+
]}
50+
*)
51+
3552
type condition
3653

3754
val ip : string -> condition

src/extensions/authbasic.mli

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,30 @@
2020

2121
(** Authbasic: Basic HTTP authentication *)
2222

23-
(** If you want to use this extension with Ocsigen Server's configuration file,
24-
+ have a look at the {% <<a_manual chapter="authbasic"|manual page>>%}.
25-
+ If you are using Ocsigen Server as a library, use the interface described
26-
+ here. Each of these functions behaves exactly as its configuration file
27-
counterpart.
28-
+*)
23+
(** If you want to use this extension with Ocsigen Server's configuration file,
24+
have a look at the {% <<a_manual chapter="authbasic"|manual page>>%}.
25+
If you are using Ocsigen Server as a library, use the interface described
26+
here. Each of these functions behaves exactly as its configuration file
27+
counterpart.
28+
*)
2929

3030
(**
3131
This module belongs to ocamlfind package
3232
[ocsigenserver.ext.authbasic].
3333
*)
3434

35+
(** Example of use:
36+
{[
37+
let _ =
38+
Ocsigen_server.start
39+
[ Ocsigen_server.host ~regexp:".*"
40+
[ Authbasic.run ~realm:"test"
41+
~auth:(fun u p -> Lwt.return (u = "theuser" && p = "thepassword"))
42+
()
43+
; Staticmod.run ~dir:"static" () ]]
44+
]}
45+
*)
46+
3547
(** This module implements Basic HTTP Authentication as described in
3648
{{:http://www.ietf.org/rfc/rfc2617.txt}RFC 2617}. It can be used
3749
to add an authentication layer to sites with no built-in
@@ -45,7 +57,7 @@ This module belongs to ocamlfind package
4557
in the configuration file) is provided. *)
4658

4759
val section : Lwt_log_core.section
48-
(** use Lwt_log.Section.set_level in order to set the log level *)
60+
(** use [Lwt_log.Section.set_level] in order to set the log level *)
4961

5062
type auth = string -> string -> bool Lwt.t
5163

src/extensions/cors.mli

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
11
(** Cross-Origin Resource Sharing *)
22

33
(** If you want to use this extension with Ocsigen Server's configuration file,
4-
+ have a look at the {% <<a_manual chapter="cors"|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-
+*)
4+
have a look at the {% <<a_manual chapter="cors"|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.cors].
1313
*)
1414

15+
(** Example of use:
16+
{[
17+
let _ =
18+
Ocsigen_server.start
19+
[ Ocsigen_server.host ~regexp:".*"
20+
[ Staticmod.run ~dir:"static" ()
21+
; Eliom.run ()
22+
; Cors.run
23+
~max_age:86400
24+
~credentials:true
25+
~methods:[ `POST; `GET; `HEAD ]
26+
~exposed_headers:[ "x-eliom-application"
27+
; "x-eliom-location"
28+
; "x-eliom-set-process-cookies"
29+
; "x-eliom-set-cookie-substitutes" ]
30+
()
31+
]]
32+
]}
33+
*)
34+
1535
val run :
1636
?credentials:bool
1737
-> ?max_age:int

src/extensions/deflatemod.mli

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ This module belongs to ocamlfind package
1212
[ocsigenserver.ext.deflatemod].
1313
*)
1414

15+
(** Example of use:
16+
{[
17+
let _ =
18+
Ocsigen_server.start
19+
[ Ocsigen_server.host ~regexp:".*"
20+
[ Staticmod.run ~dir:"static" ()
21+
; Deflatemod.run
22+
~mode:(`Only [ `Type (Some "text", Some "html")
23+
; `Type (Some "text", Some "javascript")
24+
; `Type (Some "text", Some "css")
25+
; `Type (Some "application", Some "javascript")
26+
; `Type (Some "application", Some "x-javascript")
27+
; `Type (Some "application", Some "xhtml+xml")
28+
; `Type (Some "image", Some "svg+xml")
29+
; `Type (Some "application", Some "x-eliom")]) ()
30+
]]
31+
]}
32+
*)
33+
1534
val set_compress_level : int -> unit
1635
val set_buffer_size : int -> unit
1736

src/extensions/extendconfiguration.mli

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(** Extendconfiguration: More configuration options for Ocsigen 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="extendconfiguration"|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
3+
(** If you want to use this extension with Ocsigen Server's configuration file,
4+
have a look at the {% <<a_manual chapter="extendconfiguration"|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
77
counterpart.
88
+*)
99

@@ -12,6 +12,18 @@ This module belongs to ocamlfind package
1212
[ocsigenserver.ext.extendconfiguration].
1313
*)
1414

15+
(** Example of use:
16+
{[
17+
let _ =
18+
Ocsigen_server.start
19+
[ Ocsigen_server.host ~regexp:".*"
20+
[ Extendconfiguration.forbidfile ~extensions:["php"] ()
21+
; Staticmod.run ~dir:"static" ()
22+
]
23+
]
24+
]}
25+
*)
26+
1527
val followsymlinks :
1628
[`Always | `No | `Owner_match]
1729
-> Ocsigen_server.instruction

src/extensions/outputfilter.mli

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(** Outputfilter: Rewrite some part of the output *)
22

3-
(** If you want to use this extension with Ocsigen Server's configuration file,
4-
+ have a look at the {% <<a_manual chapter="outputfilter"|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
3+
(** If you want to use this extension with Ocsigen Server's configuration file,
4+
have a look at the {% <<a_manual chapter="outputfilter"|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
77
counterpart.
88
+*)
99

@@ -12,6 +12,8 @@ This module belongs to ocamlfind package
1212
[ocsigenserver.ext.outputfilter].
1313
*)
1414

15+
(** See an example of use on the API documentation of {!Revproxy}. *)
16+
1517
val run :
1618
mode:
1719
[ `Rewrite of Ocsigen_header.Name.t * string * string

src/extensions/redirectmod.mli

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
11
(** Redirectmod: HTTP redirections *)
22

3-
(** If you want to use this extension with Ocsigen Server's configuration file,
4-
+ have a look at the {% <<a_manual chapter="redirectmod"|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="redirectmod"|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.redirectmod].
1313
*)
1414

15+
(** Example of use:
16+
{[
17+
let _ =
18+
Ocsigen_server.start
19+
[ Ocsigen_server.host ~regexp:".*"
20+
[ Redirectmod.run
21+
~redirection:
22+
(Redirectmod.create_redirection
23+
~temporary:false ~full_url:false ~regexp:"^olddir/(.* )$"
24+
"https://blahblahblah.org/newdir/\\1")
25+
()
26+
; Staticmod.run ~dir:"static" ()
27+
]
28+
]
29+
]}
30+
*)
31+
1532
val section : Lwt_log_core.section
1633
(** use Lwt_log.Section.set_level in order to set the log level *)
1734

src/extensions/revproxy.mli

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,28 @@ This module belongs to ocamlfind package
1212
[ocsigenserver.ext.revproxy].
1313
*)
1414

15-
(** Example of use:
15+
(** Example of use. Forward all requests to a given directory to the
16+
same directory of another server running locally on another port.
17+
We are using it in combination with
18+
{% <<a_manual chapter="outputfilter"|Outputfilter>>%} to rewrite redirections.
19+
1620
{[
1721
let _ =
1822
Ocsigen_server.start
1923
[ Ocsigen_server.host ~regexp:".*"
20-
[ Ocsigen_server.site ["blah"]
21-
[ Revproxy.run
22-
~redirection:(Revproxy.create_redirection ) ]]]
24+
[ Revproxy.run
25+
~redirection:(Revproxy.create_redirection
26+
~full_url:false
27+
~regexp:"(othersite/.* )"
28+
~keephost:true
29+
"https://localhost:8123/\\1")
30+
()
31+
; Outputfilter.run
32+
~mode:(`Rewrite (Ocsigen_header.Name.location,
33+
"http://localhost:8123/(.* )",
34+
"http://my.publicaddress.org/\\1"))
35+
()
36+
]]
2337
]}
2438
*)
2539

src/extensions/rewritemod.mli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(** Rewrite: Change the request *)
22

33
(** If you want to use this extension with Ocsigen Server's configuration file,
4-
+ have a look at the {% <<a_manual chapter="rewritemod"|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
4+
have a look at the {% <<a_manual chapter="rewritemod"|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
77
counterpart.
88
+*)
99

0 commit comments

Comments
 (0)