summaryrefslogtreecommitdiff
path: root/bin/main.ml
blob: 7e537a7222b01c503b5dcbecc4807e64dc77a943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[@@@warning "-26-27-32"]

open! StdLabels
open Eio
open Piaf

let request_handler Server.{ request; _ } =
  match Rinha.Router.match_route request.meth request.target with
  | Some handler -> handler request
  | None -> Response.create `Not_found
;;

let () =
  Eio_main.run
  @@ fun env ->
  Switch.run
  @@ fun sw ->
  let config =
    let interface = Net.Ipaddr.V4.any in
    let port = 3000 in
    `Tcp (interface, port)
  in
  let config = Server.Config.create config in
  let server = Server.create ~config request_handler in
  ignore @@ Server.Command.start ~sw env server
;;