wip: routes

This commit is contained in:
Simon Cruanes 2024-02-24 09:42:32 -05:00
parent 8f33a77017
commit a764c6c743
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -683,6 +683,35 @@ type upgrade_handler = (module UPGRADE_HANDLER)
exception Upgrade of unit Request.t * upgrade_handler exception Upgrade of unit Request.t * upgrade_handler
module Routes = struct
module Component = struct
type t = Exact of string | String | Int | Rest
let compare : t -> t -> int = Stdlib.compare
end
module C_map = Map.Make (Component)
type handler =
| Handler : {
meth: Meth.t option;
route: ('a, string Request.t -> Response.t) Route.t;
f: 'a;
}
-> handler
| Upgrade : { route: ('a, upgrade_handler) Route.t; f: 'a } -> handler
| SSE : {
route:
( 'a,
string Request.t -> (module SERVER_SENT_GENERATOR) -> unit )
Route.t;
f: 'a;
}
-> handler
type t = { leaf: handler list; sub: t C_map.t }
end
module type IO_BACKEND = sig module type IO_BACKEND = sig
val init_addr : unit -> string val init_addr : unit -> string
val init_port : unit -> int val init_port : unit -> int