Module Ocsigen


module Ocsigen: sig .. end
Ocsigen.ml defines the functions you need to interact with the Ocsigenmod module:

val get_config : unit -> Simplexmlparser.ExprOrPatt.texprpatt Simplexmlparser.ExprOrPatt.tlist
Allows extensions of the configuration file for your modules

Put your options between <module ...> and </module>

val sync : ('a -> 'b -> 'c -> 'd) -> 'a -> 'b -> 'c -> 'd Lwt.t
This function may be used for services that can not be interrupted (no cooperation point for threads). It is defined by let sync f sp g p = Lwt.return (f sp g p)

Types


type service_kind = [ `External_Service
| `Internal_Service of [ `Local_Service | `Public_Service ] ]
Kind of service
type ('a, 'b, +'c, +'d, +'e, +'f) service 
Typed services. The 'kind parameter is subset of service_kind. 'get and 'post are the type of GET and POST parameters.
type url_path = string list 
This type is used to represent URL paths; For example the path coucou/ciao is represented by the list ["coucou";"ciao"]

Types of pages parameters



Here are some examples of how to specify the types and names of pages parameters:
type server_params 
Type of server parameters
val get_user_agent : server_params -> string
val get_hostname : server_params -> string option
val get_full_url : server_params -> string
val get_inet_addr : server_params -> Unix.inet_addr
val get_ip : server_params -> string
val get_port : server_params -> int
val get_get_params : server_params -> (string * string) list
val get_post_params : server_params -> (string * string) list Lwt.t
val get_current_url : server_params -> url_path
val get_tmp_filename : Extensions.file_info -> string
Type of files
val get_filesize : Extensions.file_info -> int64
val get_original_filename : Extensions.file_info -> string

type ('a, 'b) binsum =
| Inj1 of 'a
| Inj2 of 'b (*Binary sums*)
type 'a param_name 
Type for names of page parameters
type ('a, 'b, 'c) params_type 
Type for parameters of a web page

type 'a listnames = {
   it : 'b 'c. ('a -> 'b -> 'c list) -> 'b list -> 'c list -> 'c list;
}
Type of the iterator used to construct forms from lists
val int : string ->
(int, [ `WithoutSuffix ], int param_name) params_type
int s tells that the page takes an integer as parameter, labeled s
val float : string ->
(float, [ `WithoutSuffix ], float param_name) params_type
float s tells that the page takes a floating point number as parameter, labeled s
val string : string ->
(string, [ `WithoutSuffix ], string param_name) params_type
string s tells that the page takes a string as parameter, labeled s
val bool : string ->
(bool, [ `WithoutSuffix ], bool param_name) params_type
bool s tells that the page takes a boolean as parameter, labeled s (to use for example with boolean checkboxes)
val file : string ->
(Extensions.file_info, [ `WithoutSuffix ],
Extensions.file_info param_name)
params_type
file s tells that the page takes a file as parameter, labeled s
val radio_answer : string ->
(string option, [ `WithoutSuffix ], string option param_name)
params_type
radio_answer s tells that the page takes the result of a click on a radio button as parameter.
val unit : (unit, [ `WithoutSuffix ], unit param_name) params_type
used for pages that don't have any parameters
val user_type : (string -> 'a) ->
('a -> string) ->
string -> ('a, [ `WithoutSuffix ], 'a param_name) params_type
Allows to use whatever type you want for a parameter of the page. user_type s_to_t t_to_s s tells that the page take a parameter, labeled s, and that the server will have to use s_to_t and t_to_s to make the conversion from and to string.
val sum : ('a, [ `WithoutSuffix ], 'b) params_type ->
('a, [ `WithoutSuffix ], 'b) params_type ->
(('a, 'a) binsum, [ `WithoutSuffix ], 'b * 'b) params_type
val prod : ('a, [ `WithoutSuffix ], 'b) params_type ->
('c, [ `WithoutSuffix ], 'd) params_type ->
('a * 'c, [ `WithoutSuffix ], 'b * 'd) params_type
See ** above
val opt : ('a, [ `WithoutSuffix ], 'b) params_type ->
('a option, [ `WithoutSuffix ], 'b) params_type
Use this if you want a parameter to be optional
val list : string ->
('a, [ `WithoutSuffix ], 'b) params_type ->
('a list, [ `WithoutSuffix ], 'b listnames) params_type
The page takes a list of parameters. The first parameter of this function is the name of the list.
val (**) : ('a, [ `WithoutSuffix ], 'b) params_type ->
('c, [ `WithoutSuffix ], 'd) params_type ->
('a * 'c, [ `WithoutSuffix ], 'b * 'd) params_type
This is a combinator to allow the page to take several parameters (see examples above) Warning: it is a binary operator. Pages cannot take tuples but only pairs.
val suffix_only : (string, [ `WithSuffix ], string param_name) params_type
Tells that the only parameter of the function that will generate the page is the suffix of the URL of the current page. (see register_new_service)
val suffix : ('a, [ `WithoutSuffix ], 'b) params_type ->
(string * 'a, [ `WithSuffix ], string param_name * 'b)
params_type
Tells that the function that will generate the page takes a pair whose first element is the suffix of the URL of the current page. (see register_new_service). e.g. suffix (int "i" ** string "s")
module Xhtml: sig .. end
Pages registration (typed xhtml)

Using other ways (than the module Ocsigen.Xhtml) to create pages


module type PAGES = sig .. end
module type OCSIGENSIG = sig .. end
module Make: 
functor (Pages : PAGES) -> OCSIGENSIG with type page = Pages.page and type form_content_elt = Pages.form_content_elt and type form_content_elt_list = Pages.form_content_elt_list and type form_elt = Pages.form_elt and type a_content_elt = Pages.a_content_elt and type a_content_elt_list = Pages.a_content_elt_list and type a_elt = Pages.a_elt and type a_elt_list = Pages.a_elt_list and type div_content_elt = Pages.div_content_elt and type div_content_elt_list = Pages.div_content_elt_list and type uri = Pages.uri and type link_elt = Pages.link_elt and type script_elt = Pages.script_elt and type textarea_elt = Pages.textarea_elt and type select_elt = Pages.select_elt and type input_elt = Pages.input_elt and type pcdata_elt = Pages.pcdata_elt and type a_attrib_t = Pages.a_attrib_t and type form_attrib_t = Pages.form_attrib_t and type input_attrib_t = Pages.input_attrib_t and type textarea_attrib_t = Pages.textarea_attrib_t and type select_attrib_t = Pages.select_attrib_t and type link_attrib_t = Pages.link_attrib_t and type script_attrib_t = Pages.script_attrib_t and type input_type_t = Pages.input_type_t
module Text: OCSIGENSIG  with 
type page = string
and type form_content_elt = string
and type form_content_elt_list = string
and type form_elt = string 
and type a_content_elt = string 
and type a_content_elt_list = string 
and type a_elt = string 
and type a_elt_list = string 
and type div_content_elt = string 
and type div_content_elt_list = string 
and type uri = string 
and type link_elt = string 
and type script_elt = string 
and type textarea_elt = string 
and type select_elt = string 
and type input_elt = string 
and type pcdata_elt = string 
and type a_attrib_t = string 
and type form_attrib_t = string 
and type input_attrib_t = string 
and type textarea_attrib_t = string 
and type select_attrib_t = string 
and type link_attrib_t = string 
and type script_attrib_t = string 
and type input_type_t = string