diff options
Diffstat (limited to 'bin/main.ml')
-rw-r--r-- | bin/main.ml | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/bin/main.ml b/bin/main.ml index 7e537a7..99cc0e0 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -4,9 +4,9 @@ open! StdLabels open Eio open Piaf -let request_handler Server.{ request; _ } = +let request_handler ~db_pool Server.{ request; _ } = match Rinha.Router.match_route request.meth request.target with - | Some handler -> handler request + | Some handler -> handler db_pool request | None -> Response.create `Not_found ;; @@ -17,10 +17,16 @@ let () = @@ fun sw -> let config = let interface = Net.Ipaddr.V4.any in - let port = 3000 in + let port = 8080 in `Tcp (interface, port) in let config = Server.Config.create config in - let server = Server.create ~config request_handler in + let db_uri = + Uri.make ~scheme:"postgres" ~userinfo:"admin:123" ~host:"db" ~path:"rinha" () + in + let db_pool = + Result.get_ok @@ Caqti_eio.connect_pool ~sw ~stdenv:(env :> Caqti_eio.stdenv) db_uri + in + let server = Server.create ~config (request_handler ~db_pool) in ignore @@ Server.Command.start ~sw env server ;; |