Skip to content

Commit cf779dc

Browse files
committed
use piaf-lwt
1 parent 3068c5b commit cf779dc

File tree

9 files changed

+37
-19
lines changed

9 files changed

+37
-19
lines changed

lib/client.ml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
*---------------------------------------------------------------------------*)
3232

3333
open Lwt.Infix
34+
module Piaf = Piaf_lwt
3435

3536
module Constants = struct
3637
let runtime_api_version = "2018-06-01"

lib/dune

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,14 @@
33
(public_name lambda-runtime)
44
(preprocess
55
(pps ppx_deriving_yojson))
6-
(libraries yojson ppx_deriving_yojson.runtime bigstringaf bigarray-compat
7-
uri logs.lwt lwt lwt.unix piaf result))
6+
(libraries
7+
yojson
8+
ppx_deriving_yojson.runtime
9+
bigstringaf
10+
bigarray-compat
11+
uri
12+
logs.lwt
13+
lwt
14+
lwt.unix
15+
piaf-lwt
16+
result))

lib/runtime.ml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
*---------------------------------------------------------------------------*)
3232

3333
open Lwt.Infix
34+
module Piaf = Piaf_lwt
3435

3536
module Make
3637
(Event : Runtime_intf.LambdaEvent)

vercel/dune

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
(library
22
(public_name vercel)
3-
(libraries bigstringaf lwt lambda-runtime yojson ppx_deriving_yojson.runtime
4-
result base64 piaf)
3+
(libraries
4+
bigstringaf
5+
lwt
6+
lambda-runtime
7+
yojson
8+
ppx_deriving_yojson.runtime
9+
result
10+
base64
11+
piaf-lwt)
512
(preprocess
613
(pps ppx_deriving_yojson)))

vercel/message.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*---------------------------------------------------------------------------*)
3232

3333
module StringMap = Lambda_runtime.StringMap
34-
module Headers = Piaf.Headers
34+
module Headers = Piaf_lwt.Headers
3535

3636
let decode_body ~encoding body =
3737
match body, encoding with

vercel/request.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
*---------------------------------------------------------------------------*)
3232

3333
module StringMap = Lambda_runtime.StringMap
34-
module Request = Piaf.Request
35-
module Body = Piaf.Body
36-
module Headers = Piaf.Headers
34+
module Request = Piaf_lwt.Request
35+
module Body = Piaf_lwt.Body
36+
module Headers = Piaf_lwt.Headers
3737

3838
type vercel_proxy_request =
3939
{ path : string
@@ -60,7 +60,7 @@ let of_yojson json =
6060
Yojson.Safe.from_string event_body |> vercel_proxy_request_of_yojson
6161
with
6262
| Ok { body; encoding; path; http_method; host; headers } ->
63-
let meth = Piaf.Method.of_string http_method in
63+
let meth = Piaf_lwt.Method.of_string http_method in
6464
let headers =
6565
Message.string_map_to_headers
6666
~init:
@@ -83,7 +83,7 @@ let of_yojson json =
8383
let request =
8484
Request.create
8585
~scheme:HTTP
86-
~version:Piaf.Versions.HTTP.v1_1
86+
~version:Piaf_lwt.Versions.HTTP.v1_1
8787
~headers
8888
~meth
8989
~body

vercel/response.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*---------------------------------------------------------------------------*)
3232

3333
module StringMap = Lambda_runtime.StringMap
34-
module Response = Piaf.Response
34+
module Response = Piaf_lwt.Response
3535

3636
type vercel_proxy_response =
3737
{ status_code : int [@key "statusCode"]
@@ -48,11 +48,11 @@ let to_yojson { Response.status; headers; body; _ } =
4848
(fun body ->
4949
let body = Result.get_ok body in
5050
let vercel_proxy_response =
51-
{ status_code = Piaf.Status.to_code status
51+
{ status_code = Piaf_lwt.Status.to_code status
5252
; headers = Message.headers_to_string_map headers
5353
; body
5454
; encoding = None
5555
}
5656
in
5757
vercel_proxy_response_to_yojson vercel_proxy_response)
58-
(Piaf.Body.to_string body)
58+
(Piaf_lwt.Body.to_string body)

vercel/vercel.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
include Lambda_runtime.Make (Request) (Response)
3434

3535
(* Proxy to Piaf for Headers, Request and Response for convenience *)
36-
module Headers = Piaf.Headers
37-
module Request = Piaf.Request
38-
module Response = Piaf.Response
36+
module Headers = Piaf_lwt.Headers
37+
module Request = Piaf_lwt.Request
38+
module Response = Piaf_lwt.Response

vercel/vercel.mli

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ open Lambda_runtime
3535
(* To keep module equality. See e.g.:
3636
* https://stackoverflow.com/a/37307124/3417023 *)
3737
module Headers : module type of struct
38-
include Piaf.Headers
38+
include Piaf_lwt.Headers
3939
end
4040

4141
module Request : module type of struct
42-
include Piaf.Request
42+
include Piaf_lwt.Request
4343
end
4444

4545
module Response : module type of struct
46-
include Piaf.Response
46+
include Piaf_lwt.Response
4747
end
4848

4949
include

0 commit comments

Comments
 (0)