clean up skeleton

This commit is contained in:
swrup 2025-11-05 19:41:38 +01:00
parent f4eb197093
commit 928d68fdc5
6 changed files with 100 additions and 810 deletions

View file

@ -1 +1,46 @@
let uuu = "uuu"
module Method = H2.Method
module Headers = H2.Headers
module Status = H2.Status
type request = {
meth: Method.t;
target: string;
scheme: string;
headers: Headers.t;
}
type response = {
status: Status.t;
headers: Headers.t;
content: string;
}
let request_route request =
match String.split_on_char '/' request.target with
| "" :: l -> l
| _ -> assert false
let content_type_to_string = function
| `Text_plain -> "text/plain"
| `Application_json -> "application/json"
let default_headers ~content typ =
Headers.of_list
[
("content-length", string_of_int (String.length content));
("connection", "close"); ("content-type", content_type_to_string typ);
]
let home_page_text =
"Hello!\n\nThis is MTE, the MirageOS Taler Exchange unikernel."
let request_handler request =
match request_route request with
| [ "" ] ->
let content = home_page_text in
let headers = default_headers ~content `Text_plain in
{ status= `OK; headers; content }
| _ ->
let content = "Not found." in
let headers = default_headers ~content `Text_plain in
{ status= `Not_found; headers; content }