Skip to content

Commit

Permalink
Static linking: update to new Ocsigen Server interface
Browse files Browse the repository at this point in the history
  • Loading branch information
balat committed May 10, 2024
1 parent 2a57f11 commit 262c9c8
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 141 deletions.
86 changes: 72 additions & 14 deletions src/lib/eliom.server.ml
Original file line number Diff line number Diff line change
@@ -1,20 +1,78 @@
let run ?site ?app ?xhr_links ?data_timeout ?service_timeout ?persistent_timeout
?max_service_sessions_per_group ?max_volatile_data_sessions_per_group
let default_app_name = Eliom_common.default_app_name
let set_app_name = Eliommod.set_app_name

let run ?(app = default_app_name) ?xhr_links ?data_timeout ?service_timeout
?persistent_timeout ?max_service_sessions_per_group
?max_volatile_data_sessions_per_group
?max_persistent_data_sessions_per_group ?max_service_tab_sessions_per_group
?max_volatile_data_tab_sessions_per_group
?max_persistent_data_tab_sessions_per_group
?max_anonymous_services_per_session ?secure_cookies ?application_script
?global_data_caching ?html_content_type ?ignored_get_params
?ignored_post_params ?omitpersistentstorage ()
?ignored_post_params ?omitpersistentstorage () vh conf_info site_dir
=
Ocsigen_server.Site.register ?site
(Eliom_registration.instruction ?app ?xhr_links ?data_timeout
?service_timeout ?persistent_timeout ?max_service_sessions_per_group
?max_volatile_data_sessions_per_group
?max_persistent_data_sessions_per_group
?max_service_tab_sessions_per_group
?max_volatile_data_tab_sessions_per_group
?max_persistent_data_tab_sessions_per_group
?max_anonymous_services_per_session ?secure_cookies ?application_script
?global_data_caching ?html_content_type ?ignored_get_params
?ignored_post_params ?omitpersistentstorage ())
let sitedata = Eliommod.update_sitedata app vh site_dir conf_info in
(* customize sitedata according to optional parameters: *)
Option.iter
(fun v ->
sitedata.Eliom_common.default_links_xhr#set ~override_tenable:true v)
xhr_links;
Option.iter
(fun (level, hierarchyname, v) ->
Eliommod.set_timeout
(Eliommod_timeouts.set_global_ ~kind:`Data)
sitedata level hierarchyname v)
data_timeout;
Option.iter
(fun (level, hierarchyname, v) ->
Eliommod.set_timeout
(Eliommod_timeouts.set_global_ ~kind:`Service)
sitedata level hierarchyname v)
service_timeout;
Option.iter
(fun (level, hierarchyname, v) ->
Eliommod.set_timeout
(Eliommod_timeouts.set_global_ ~kind:`Persistent)
sitedata level hierarchyname v)
persistent_timeout;
Option.iter
(fun v -> sitedata.max_service_sessions_per_group <- v)
max_service_sessions_per_group;
Option.iter
(fun v -> sitedata.max_volatile_data_sessions_per_group <- v)
max_volatile_data_sessions_per_group;
Option.iter
(fun v -> sitedata.max_persistent_data_sessions_per_group <- Some v, true)
max_persistent_data_sessions_per_group;
Option.iter
(fun v -> sitedata.max_service_tab_sessions_per_group <- v)
max_service_tab_sessions_per_group;
Option.iter
(fun v -> sitedata.max_volatile_data_tab_sessions_per_group <- v)
max_volatile_data_tab_sessions_per_group;
Option.iter
(fun v ->
sitedata.max_persistent_data_tab_sessions_per_group <- Some v, true)
max_persistent_data_tab_sessions_per_group;
Option.iter
(fun v -> sitedata.max_anonymous_services_per_session <- v)
max_anonymous_services_per_session;
Option.iter (fun v -> sitedata.secure_cookies <- v) secure_cookies;
Option.iter (fun v -> sitedata.application_script <- v) application_script;
Option.iter (fun v -> sitedata.cache_global_data <- v) global_data_caching;
Option.iter (fun v -> sitedata.html_content_type <- Some v) html_content_type;
Option.iter
(fun v -> sitedata.ignored_get_params <- v :: sitedata.ignored_get_params)
ignored_get_params;
Option.iter
(fun v -> sitedata.ignored_post_params <- v :: sitedata.ignored_post_params)
ignored_post_params;
Option.iter
(fun v -> sitedata.omitpersistentstorage <- v)
omitpersistentstorage;
(* end sitedata *)
Eliom_common.absolute_change_sitedata sitedata;
Eliommod.site_init (ref true);
(* Load app: *)
Eliommod.load_eliom_module sitedata (Eliommod.Name app) "" [];
Eliommod_pagegen.gen None sitedata
20 changes: 14 additions & 6 deletions src/lib/eliom.server.mli
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
val set_app_name : string -> unit
(** Set your application name. Use this if you want to make it possible
to link your Eliom application statically and to have several Eliom
applications on the same Web server.
See also parameter [?app_names] of [instruction] or [Eliom.run].
*)

val default_app_name : string
(** The default application name, if you don't specify any *)

val run :
?site:Ocsigen_server.Site.t
-> ?app:string
?app:string
-> ?xhr_links:bool
-> ?data_timeout:
[< Eliom_common.cookie_level]
Expand Down Expand Up @@ -29,9 +38,8 @@ val run :
-> ?ignored_post_params:string * Re.re
-> ?omitpersistentstorage:Eliom_common.omitpersistentstorage_rule list option
-> unit
-> unit
(** [run ?site ?app ()] run Eliom application [app] under site [site].
-> Ocsigen_server.instruction
(** [run ?app ()] run Eliom application [app] under current site.
Use this to build a static executable without configuration file.
Default values are default site (root of the Web site on all virtual hosts)
and default app name.
Default value of [?app] is [default_app_name].
Other optional values correspond to Eliom configuration for this site. *)
79 changes: 0 additions & 79 deletions src/lib/eliom_registration.server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1260,82 +1260,3 @@ let set_exn_handler h =
let sitedata = Eliom_request_info.find_sitedata "set_exn_handler" in
Eliom_request_info.set_site_handler sitedata
(Result_types.cast_function_http h)

let default_app_name = Eliom_common.default_app_name
let set_app_name = Eliommod.set_app_name

let instruction ?xhr_links ?(app = default_app_name) ?data_timeout
?service_timeout ?persistent_timeout ?max_service_sessions_per_group
?max_volatile_data_sessions_per_group
?max_persistent_data_sessions_per_group ?max_service_tab_sessions_per_group
?max_volatile_data_tab_sessions_per_group
?max_persistent_data_tab_sessions_per_group
?max_anonymous_services_per_session ?secure_cookies ?application_script
?global_data_caching ?html_content_type ?ignored_get_params
?ignored_post_params ?omitpersistentstorage () vh conf_info site_dir
=
let sitedata = Eliommod.update_sitedata app vh site_dir conf_info in
(* customize sitedata according to optional parameters: *)
Option.iter
(fun v ->
sitedata.Eliom_common.default_links_xhr#set ~override_tenable:true v)
xhr_links;
Option.iter
(fun (level, hierarchyname, v) ->
Eliommod.set_timeout
(Eliommod_timeouts.set_global_ ~kind:`Data)
sitedata level hierarchyname v)
data_timeout;
Option.iter
(fun (level, hierarchyname, v) ->
Eliommod.set_timeout
(Eliommod_timeouts.set_global_ ~kind:`Service)
sitedata level hierarchyname v)
service_timeout;
Option.iter
(fun (level, hierarchyname, v) ->
Eliommod.set_timeout
(Eliommod_timeouts.set_global_ ~kind:`Persistent)
sitedata level hierarchyname v)
persistent_timeout;
Option.iter
(fun v -> sitedata.max_service_sessions_per_group <- v)
max_service_sessions_per_group;
Option.iter
(fun v -> sitedata.max_volatile_data_sessions_per_group <- v)
max_volatile_data_sessions_per_group;
Option.iter
(fun v -> sitedata.max_persistent_data_sessions_per_group <- Some v, true)
max_persistent_data_sessions_per_group;
Option.iter
(fun v -> sitedata.max_service_tab_sessions_per_group <- v)
max_service_tab_sessions_per_group;
Option.iter
(fun v -> sitedata.max_volatile_data_tab_sessions_per_group <- v)
max_volatile_data_tab_sessions_per_group;
Option.iter
(fun v ->
sitedata.max_persistent_data_tab_sessions_per_group <- Some v, true)
max_persistent_data_tab_sessions_per_group;
Option.iter
(fun v -> sitedata.max_anonymous_services_per_session <- v)
max_anonymous_services_per_session;
Option.iter (fun v -> sitedata.secure_cookies <- v) secure_cookies;
Option.iter (fun v -> sitedata.application_script <- v) application_script;
Option.iter (fun v -> sitedata.cache_global_data <- v) global_data_caching;
Option.iter (fun v -> sitedata.html_content_type <- Some v) html_content_type;
Option.iter
(fun v -> sitedata.ignored_get_params <- v :: sitedata.ignored_get_params)
ignored_get_params;
Option.iter
(fun v -> sitedata.ignored_post_params <- v :: sitedata.ignored_post_params)
ignored_post_params;
Option.iter
(fun v -> sitedata.omitpersistentstorage <- v)
omitpersistentstorage;
(* end sitedata *)
Eliom_common.absolute_change_sitedata sitedata;
Eliommod.site_init (ref true);
(* Load app: *)
Eliommod.load_eliom_module sitedata (Eliommod.Name app) "" [];
Eliommod_pagegen.gen None sitedata
42 changes: 0 additions & 42 deletions src/lib/eliom_registration.server.mli
Original file line number Diff line number Diff line change
Expand Up @@ -487,45 +487,3 @@ val cast_unknown_content_kind : unknown_content kind -> 'a kind
val cast_http_result : Ocsigen_response.t -> 'a kind
(** [cast_http_result] should only be used to register new output
modules *)

val set_app_name : string -> unit
(** Set your application name. Use this if you want to make it possible
to link your Eliom application statically and to have several Eliom
applications on the same Web server.
See also parameter [?app_names] of [instruction] or [Eliom.run].
*)

val default_app_name : string
(** The default application name, if you don't specify any *)

val instruction :
?xhr_links:bool
-> ?app:string
-> ?data_timeout:
[< Eliom_common.cookie_level]
* Eliom_common_base.scope_hierarchy option
* float option
-> ?service_timeout:
[< Eliom_common.cookie_level]
* Eliom_common_base.scope_hierarchy option
* float option
-> ?persistent_timeout:
[< Eliom_common.cookie_level]
* Eliom_common_base.scope_hierarchy option
* float option
-> ?max_service_sessions_per_group:int * bool
-> ?max_volatile_data_sessions_per_group:int * bool
-> ?max_persistent_data_sessions_per_group:int
-> ?max_service_tab_sessions_per_group:int * bool
-> ?max_volatile_data_tab_sessions_per_group:int * bool
-> ?max_persistent_data_tab_sessions_per_group:int
-> ?max_anonymous_services_per_session:int * bool
-> ?secure_cookies:bool
-> ?application_script:bool * bool
-> ?global_data_caching:(string list * int) option
-> ?html_content_type:string
-> ?ignored_get_params:string * Re.re
-> ?ignored_post_params:string * Re.re
-> ?omitpersistentstorage:Eliom_common.omitpersistentstorage_rule list option
-> unit
-> Ocsigen_server.Site.instruction

0 comments on commit 262c9c8

Please sign in to comment.