diff options
author | filip <“filip.rabiega@gmail.com”> | 2024-08-16 14:11:00 +0200 |
---|---|---|
committer | filip <“filip.rabiega@gmail.com”> | 2024-08-16 14:11:00 +0200 |
commit | 69de932f9116b30adfd689d38e35ace63aef0e2d (patch) | |
tree | f7e8621889d313e70186ef255fcf04fe0d55d4c3 /api/startapp.ml | |
parent | 2e893fd0df7dae8c4ae843d4a23acb098dd97aff (diff) | |
download | chadprover-master.tar.gz chadprover-master.tar.bz2 chadprover-master.zip |
Diffstat (limited to 'api/startapp.ml')
-rw-r--r-- | api/startapp.ml | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/api/startapp.ml b/api/startapp.ml new file mode 100644 index 0000000..3b459d5 --- /dev/null +++ b/api/startapp.ml @@ -0,0 +1,26 @@ + +(* Middleware to enable CORS for testing purposes *) +let cors_middleware handler request = + let handlers = + [ + "Allow", "OPTIONS, GET, HEAD, POST"; + "Access-Control-Allow-Origin", "*"; + "Access-Control-Allow-Methods", "OPTIONS, GET, HEAD, POST"; + "Access-Control-Allow-Headers", "Content-Type"; + "Access-Control-Max-Age", "86400" + ] + in + + let%lwt res = handler request in + handlers + |> List.map (fun (key, value) -> Dream.add_header res key value) + |> ignore; + Lwt.return res + + (* Create and start the app *) +let startapp () = + Dream.run + @@ Dream.logger + (* @@ Dream.origin_referrer_check *) + @@ cors_middleware (* TODO: remove *) + @@ Dream.router Routes.routes |