@@ -33,15 +33,15 @@ let date () =
33
33
34
34
(* HTTP *)
35
35
36
- let _plaintext date reqd =
36
+ let _plaintext reqd =
37
37
let open H1 in
38
38
let payload = " Hello, World!" in
39
39
let headers =
40
40
Headers. of_rev_list
41
41
[ (" content-length" , string_of_int (String. length payload))
42
42
; (" content-type" , " text/plain" )
43
43
; (" server" , " httpcats" )
44
- ; (" date" , ! date) ] in
44
+ ; (" date" , date () ) ] in
45
45
let resp = Response. create ~headers `OK in
46
46
Reqd. respond_with_string reqd resp payload
47
47
@@ -54,7 +54,7 @@ let _json date reqd =
54
54
[ (" content-length" , string_of_int (String. length payload))
55
55
; (" content-type" , " application/json" )
56
56
; (" server" , " httpcats" )
57
- ; (" date" , ! date) ] in
57
+ ; (" date" , date () ) ] in
58
58
let resp = Response. create ~headers `OK in
59
59
Reqd. respond_with_string reqd resp payload
60
60
@@ -67,25 +67,19 @@ let _not_found reqd =
67
67
let resp = Response. create ~headers `OK in
68
68
Reqd. respond_with_string reqd resp moo
69
69
70
- let [@ warning " -8" ] handler date _
70
+ let [@ warning " -8" ] handler _
71
71
(`V1 reqd : [ `V1 of H1.Reqd.t | `V2 of H2.Reqd.t ] ) =
72
72
let open H1 in
73
73
let request = Reqd. request reqd in
74
74
match request.Request. target with
75
- | "/plaintext" -> _plaintext date reqd
76
- | "/json" -> _json date reqd
75
+ | "/plaintext" -> _plaintext reqd
76
+ | "/json" -> _json reqd
77
77
| _ -> _not_found reqd
78
78
79
79
let localhost_8080 = Unix. (ADDR_INET (inet_addr_any, 8080 ))
80
80
81
81
let server stop =
82
- let cell = ref (date () ) in
83
- let prm = Miou. async @@ fun () ->
84
- Miou_unix. sleep 1. ;
85
- cell := date () in
86
- let handler = handler cell in
87
- Httpcats.Server. clear ~parallel: false ~stop ~backlog: 4096 ~handler localhost_8080;
88
- Miou. cancel prm
82
+ Httpcats.Server. clear ~parallel: false ~stop ~backlog: 4096 ~handler localhost_8080
89
83
90
84
let () = Sys. set_signal Sys. sigpipe Sys. Signal_ignore
91
85
0 commit comments