94
94
subpath: url_path; (* name of the service without parameters *)
95
95
fullpath: url_path; (* full path of the service = site_dir@subpath *)
96
96
att_kind: 'a; (* < attached_service_kind *)
97
get_state: Eliom_common.internal_state option;
98
post_state: Eliom_common.internal_state option;
97
get_name: Eliom_common.att_key;
98
post_name: Eliom_common.att_key;
151
151
let get_prefix_ s = s.prefix
152
152
let get_sub_path_ s = s.subpath
153
153
let get_full_path_ s = s.fullpath
154
let get_get_state_ s = s.get_state
155
let get_post_state_ s = s.post_state
154
let get_get_name_ s = s.get_name
155
let get_post_name_ s = s.post_name
156
156
let get_na_name_ s = s.na_name
157
157
let get_na_kind_ s = s.na_kind
158
158
let get_max_use_ s = s.max_use
169
169
(Printf.sprintf "%x" (Random.int 0xFFFF))^(Printf.sprintf "%Lx" !c)
172
(*****************************************************************************)
173
(*****************************************************************************)
174
(* Registration of static module initialization functions *)
175
(*****************************************************************************)
176
(*****************************************************************************)
178
let register_eliom_module name f =
179
Ocsigen_loader.set_module_init_function name f
173
181
(*****************************************************************************)
174
182
(*****************************************************************************)
356
365
get_params_type = add_pref_params Eliom_common.co_param_prefix get_params;
359
get_state = Some (new_state ());
360
att_kind = `Internal (`Coservice, `Get);
370
| None -> Eliom_common.Att_anon (new_state ())
371
| Some name -> Eliom_common.Att_named name);
372
att_kind = `Internal (`Coservice, `Get);
362
374
https = https || fallback.https
364
376
(* Warning: here no GET parameters for the fallback.
365
Apply services with apply_service
366
if you want fallbacks with GET parameters *)
369
let new_coservice' ?max_use ?timeout ?(https = false) ~get_params () =
370
let n = Eliom_common.Na_get' (new_naservice_num ()) in
377
Preapply services if you want fallbacks with GET parameters *)
380
let new_coservice' ?name ?max_use ?timeout ?(https = false) ~get_params () =
371
381
(* (match Eliom_common.global_register_allowed () with
372
382
| Some _ -> Eliom_common.add_unregistered_na n;
373
383
| _ -> () (* Do we accept unregistered non-attached coservices? *)); *)
377
pre_applied_parameters = [];
378
get_params_type = add_pref_params Eliom_common.na_co_param_prefix get_params;
379
post_params_type = unit;
384
(* (* Do we accept unregistered non-attached named coservices? *)
390
(*VVV allow timeout and max_use for named coservices? *)
393
pre_applied_parameters = [];
395
add_pref_params Eliom_common.na_co_param_prefix get_params;
396
post_params_type = unit;
401
Eliom_common.Na_get' (new_naservice_num ())
402
| Some name -> Eliom_common.Na_get_ name;
387
let new_service' ?sp ?(https = false) ~name ~get_params () =
390
(match Eliom_common.global_register_allowed () with
391
| Some get_current_sitedata ->
392
let sitedata = get_current_sitedata () in
395
(*VVV allow timeout and max_use? *)
398
pre_applied_parameters = [];
400
add_pref_params Eliom_common.na_co_param_prefix get_params;
401
post_params_type = unit;
403
{na_name = Eliom_common.Na_get_ name;
409
Eliom_common.add_unregistered_na sitedata
410
(Eliom_common.Na_get_ name);
413
raise (Eliom_common.Eliom_function_forbidden_outside_site_loading
417
(*VVV allow timeout and max_use? *)
420
pre_applied_parameters = [];
422
add_pref_params Eliom_common.na_co_param_prefix get_params;
423
post_params_type = unit;
425
{na_name = Eliom_common.Na_get_ name;
431
410
(****************************************************************************)
432
411
(** Register a service with post parameters in the server *)
508
490
(*VVV Warning: keep_get_na_params is experimental *)
509
491
let new_post_coservice'
510
493
?max_use ?timeout ?(keep_get_na_params = true) ?(https = false)
511
494
~post_params () =
512
495
(* match Eliom_common.global_register_allowed () with
513
496
| Some _ -> Eliom_common.add_unregistered None
518
pre_applied_parameters = [];
519
get_params_type = unit;
520
post_params_type = post_params;
522
{na_name = Eliom_common.Na_post' (new_naservice_num ());
523
na_kind = `Post keep_get_na_params;
499
(*VVV allow timeout and max_use for named coservices? *)
502
pre_applied_parameters = [];
503
get_params_type = unit;
504
post_params_type = post_params;
509
Eliom_common.Na_post' (new_naservice_num ())
510
| Some name -> Eliom_common.Na_post_ name);
511
na_kind = `Post keep_get_na_params;
528
let new_post_service'
529
?(keep_get_na_params = true) ?(https = false) ~name ~post_params () =
530
(* match Eliom_common.global_register_allowed () with
531
| Some _ -> Eliom_common.add_unregistered None
534
(*VVV allow timeout and max_use? *)
537
pre_applied_parameters = [];
538
get_params_type = unit;
539
post_params_type = post_params;
541
{na_name = Eliom_common.Na_post_ name;
542
na_kind = `Post keep_get_na_params;
548
518
let new_get_post_coservice'
585
560
kind = match service.kind with
586
561
| `Attached k -> `Attached {k with
587
562
subpath = (match suff with
588
| Some suff -> k.subpath@suff
563
| Some suff -> append_suffix k.subpath suff
589
564
| _ -> k.subpath);
590
565
fullpath = (match suff with
591
| Some suff -> k.fullpath@suff
566
| Some suff -> append_suffix k.fullpath suff
592
567
| _ -> k.fullpath);
573
let void_coservice' =
617
592
get_params_type = unit;
618
593
post_params_type = unit;
619
594
kind = `Nonattached
620
{na_name = Eliom_common.Na_get_ "";
595
{na_name = Eliom_common.Na_void_dontkeep;
601
let void_hidden_coservice' = {void_coservice' with
603
{na_name = Eliom_common.Na_void_keep;
608
let https_void_hidden_coservice' = {void_coservice' with
610
{na_name = Eliom_common.Na_void_keep;
627
616
(*****************************************************************************)
628
617
let set_exn_handler ?sp h =