File tree Expand file tree Collapse file tree 5 files changed +16
-1
lines changed Expand file tree Collapse file tree 5 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,8 @@ let create_server ?catch ?allow_origin ?allow_headers ?allow_methods
123
123
~mode: (`TCP (`Port server_port))
124
124
(Server. make_response_action ~callback () )
125
125
126
+ let shutdown () = Lwt. return_unit
127
+
126
128
let server ?catch ?allow_origin ?allow_headers ?allow_methods ?allow_credentials ?footer servers =
127
129
Lwt. join (List. map (fun (port ,kind ) ->
128
130
create_server ?catch ?allow_origin ?allow_headers ?allow_methods ?allow_credentials ?footer
Original file line number Diff line number Diff line change @@ -113,6 +113,8 @@ let connection_handler ?catch ?allow_origin ?allow_headers ?allow_methods
113
113
sockaddr
114
114
fd
115
115
116
+ let shutdown = Server_common. shutdown
117
+
116
118
let server ?catch ?allow_origin ?allow_headers ?allow_methods ?allow_credentials ?footer servers =
117
119
Server_common. server ~name: " HTTPAF" ?catch ?allow_origin ?allow_headers
118
120
?allow_methods ?allow_credentials ?footer connection_handler servers
Original file line number Diff line number Diff line change @@ -107,5 +107,7 @@ let connection_handler ?catch ?allow_origin ?allow_headers ?allow_methods
107
107
108
108
Httpun_lwt_unix.Server. create_connection_handler ~request_handler ~error_handler sockaddr fd
109
109
110
+ let shutdown = Server_common. shutdown
111
+
110
112
let server ?catch ?allow_origin ?allow_headers ?allow_methods ?allow_credentials ?footer servers =
111
113
Server_common. server ?catch ?allow_origin ?allow_headers ?allow_methods ?allow_credentials ?footer connection_handler servers
Original file line number Diff line number Diff line change @@ -211,6 +211,8 @@ let mk_uri ~meth ~target ~header =
211
211
uri
212
212
end
213
213
214
+ let server = ref None
215
+
214
216
let create_server ?(name =" HTTPUN" ) ~max_connections server_port server_kind handler =
215
217
let open EzAPIServerUtils in
216
218
let s = { server_port; server_kind } in
@@ -222,9 +224,14 @@ let create_server ?(name="HTTPUN") ~max_connections server_port server_kind hand
222
224
~nb_max_connections: max_connections
223
225
listen_address (handler s)(* fun sockaddr fd -> *)
224
226
(* handler ?catch ?allow_origin ?allow_headers ?allow_methods *)
225
- (* ?allow_credentials s sockaddr fd) *) >> = fun _server ->
227
+ (* ?allow_credentials s sockaddr fd) *) >> = fun s ->
228
+ server := Some s;
226
229
Lwt. return_unit
227
230
231
+ let shutdown () = match ! server with
232
+ | None -> Lwt. return_unit
233
+ | Some server -> Lazy. force server.shutdown
234
+
228
235
let server ?name ?catch ?allow_origin ?allow_headers ?allow_methods ?allow_credentials ?footer handler servers =
229
236
let max_connections =
230
237
let n = List. length servers in
Original file line number Diff line number Diff line change @@ -15,4 +15,6 @@ val server : ?catch:(string -> exn -> string Answer.t Lwt.t) ->
15
15
?allow_methods : allow_kind -> ?allow_credentials : bool -> ?footer : string ->
16
16
(int * server_kind ) list -> unit Lwt .t
17
17
18
+ val shutdown : unit -> unit Lwt .t
19
+
18
20
val set_debug : unit -> unit
You can’t perform that action at this time.
0 commit comments