mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-05 19:00:32 -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
|
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
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue