Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple dream server skeleton to applications #391

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -21,6 +21,7 @@ BASE_TESTS = \
device-usage/disk-lottery \
applications/docteur \
applications/dhcp \
applications/dream \
applications/http \
applications/git \
applications/dns \
Expand Down
11 changes: 11 additions & 0 deletions applications/dream/config.ml
@@ -0,0 +1,11 @@
open Mirage

let packages = [ package "dream-mirage" ]

let http =
main "Unikernel.Make" ~packages (pclock @-> time @-> stackv4v6 @-> job)

let default_stack = generic_stackv4v6 default_network

let () =
register "dream" [ http $ default_posix_clock $ default_time $ default_stack ]
17 changes: 17 additions & 0 deletions applications/dream/unikernel.ml
@@ -0,0 +1,17 @@
module Make
(Pclock : Mirage_clock.PCLOCK)
(Time : Mirage_time.S)
(Stack : Tcpip.Stack.V4V6) =
struct
module Dream = Dream__mirage.Mirage.Make (Pclock) (Time) (Stack)

let start _pclock _time stack =
Dream.http ~port:8080 (Stack.tcp stack)
@@ Dream.logger
@@ Dream.router
[
Dream.get "/" (fun _ -> Dream.html "Good morning, world!");
Dream.get "/echo/:word" (fun request ->
Dream.html (Dream.param request "word"));
]
end