mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 11:15:35 -05:00
wip: routes
This commit is contained in:
parent
8f33a77017
commit
a764c6c743
1 changed files with 29 additions and 0 deletions
|
|
@ -683,6 +683,35 @@ type upgrade_handler = (module 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
|
||||
val init_addr : unit -> string
|
||||
val init_port : unit -> int
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue