clean up skeleton
This commit is contained in:
parent
f4eb197093
commit
12d8e72514
6 changed files with 95 additions and 810 deletions
2
src/dune
2
src/dune
|
|
@ -1,4 +1,4 @@
|
|||
(library
|
||||
(name mte)
|
||||
(wrapped false)
|
||||
(libraries logs))
|
||||
(libraries logs h1 h2))
|
||||
|
|
|
|||
42
src/mte.ml
42
src/mte.ml
|
|
@ -1 +1,41 @@
|
|||
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 home_page_text =
|
||||
"Hello!\n\nThis is MTE, the MirageOS Taler Exchange unikernel."
|
||||
|
||||
let request_handler request =
|
||||
match String.split_on_char '/' request.target with
|
||||
| [ ""; "" ] ->
|
||||
let headers =
|
||||
Headers.of_list
|
||||
[
|
||||
("content-length", string_of_int (String.length home_page_text));
|
||||
("connection", "close"); ("content-type", "text/plain");
|
||||
]
|
||||
in
|
||||
{ status= `OK; headers; content= home_page_text }
|
||||
| _ ->
|
||||
let content = "Not found." in
|
||||
let headers =
|
||||
Headers.of_list
|
||||
[
|
||||
("content-length", string_of_int (String.length content));
|
||||
("connection", "close"); ("content-type", "text/plain");
|
||||
]
|
||||
in
|
||||
{ status= `Not_found; headers; content }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue