piaf
piaf copied to clipboard
Compatibility with upstream Httpaf (Opium)
Hi there! I am currently working on a web server that serves an API which is itself a combination of multiple other APIs wrapped around a standardized interface. As such, my project needs both an http server library (to handle incoming requests) and an http client library (to forward those requests to the actual target APIs). I am using Opium (which depends on upstream Httpaf) as my main server library and I am trying to use Piaf (which depends on your fork of Httpaf) as my http client library. However, I am having the hardest time getting the project to compile because of conflicts between the two versions of Httpaf.
Any suggestions on how I can get this to work?
Here is the build error in question:
File "opium/src/app.ml", line 29, characters 31-32:
29 | Rock.Server_connection.run f app
^
Error: This expression has type
request_handler:(Httpaf.Reqd.t Gluten.reqd -> unit) ->
error_handler:Httpaf.Server_connection.error_handler -> unit Lwt.t
but an expression was expected of type
request_handler:Httpaf.Server_connection.request_handler ->
error_handler:Httpaf.Server_connection.error_handler -> 'a Lwt.t
Type Httpaf.Reqd.t Gluten.reqd -> unit is not compatible with type
Httpaf.Server_connection.request_handler = Httpaf.Reqd.t -> unit
Type Httpaf.Reqd.t Gluten.reqd = Httpaf.Reqd.t Gluten.Reqd.t
is not compatible with type Httpaf.Reqd.t
Here is part of my package.json (I am using esy):
"dependencies": {
...
"@opam/httpaf-lwt-unix": "*",
"@opam/httpaf-lwt": "*",
"@opam/httpaf": "*",
"@opam/piaf": "*",
"@opam/opium": "~0.20.0"
},
"resolutions": {
"@opam/httpaf-lwt-unix": "anmonteiro/httpaf:httpaf-lwt-unix.opam#0555dde898f0886fb9909005e00b7527cc1a3895",
"@opam/httpaf-lwt": "anmonteiro/httpaf:httpaf-lwt.opam#0555dde898f0886fb9909005e00b7527cc1a3895",
"@opam/httpaf": "anmonteiro/httpaf:httpaf.opam#0555dde898f0886fb9909005e00b7527cc1a3895"
}
Unfortunately this library is not compatible with upstream http/af, as it uses my forked version of it.
This specific interface incompatibility can be attributed to me adding support for upgrading connections (to websockets, for example).
That also means Opium can't work with it in its current state.
My resolutions
{
"resolutions": {
"@opam/httpaf": "github:anmonteiro/httpaf:httpaf.opam#559019829b7ed267a5b4b86aed1e7d7795214bcd",
"@opam/httpaf-lwt": "github:anmonteiro/httpaf:httpaf-lwt.opam#559019829b7ed267a5b4b86aed1e7d7795214bcd",
"@opam/httpaf-lwt-unix": "github:anmonteiro/httpaf:httpaf-lwt-unix.opam#559019829b7ed267a5b4b86aed1e7d7795214bcd",
"@opam/piaf": "github:EduardoRFS/piaf:piaf.opam#b93282e9c60d193d5c3572009d71b2cf3e4b81ca",
"@opam/ssl": "github:Firgeis/ocaml-ssl:ssl.opam#f7524f7b6db756ce4097dea7fa4e1c4f4f2832a9",
"@opam/opium": "github:EduardoRFS/opium:opium.opam#9fdbfbd0eedf238e1be0663ab95977be27d9a6e1",
"@opam/rock": "github:EduardoRFS/opium:rock.opam#9fdbfbd0eedf238e1be0663ab95977be27d9a6e1"
}
}