Support gleam 1.0.0
BradLewis opened this issue Β· comments
The breaking changes to Gleam 1.0.0 means that this library no longer works. In particular, with the old gleam/map
library being moved to gleam/dict
results in the following error when running with gleam v1.
β― gleam run
Compiling gleam_cowboy
error: Unknown module
ββ /Users/bradlewis/repos/gleamserver/build/packages/gleam_cowboy/src/gleam/http/cowboy.gleam:3:1
β
3 β import gleam/map.{type Map}
β ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Did you mean `list`?
No module has been found with the name `gleam/map`.
As a second part of this, after switching this to using gleam/dict
instead, I learnt that there was a breaking change in cowboy
v2.11, which results in the following error due to cookie headers.
=ERROR REPORT==== 16-Mar-2024::10:11:26.097789 ===
Ranch listener {gleam_cowboy,#Ref<0.119499685.2444492807.27282>}, connection process <0.573.0>, stream 1 had its request process <0.574.0> exit with reason {response_error,invalid_header,'Response cookies must be set using cowboy_req:set_resp_cookie/3,4.'} and stacktrace [{cowboy_req,reply,4,[{file,"/Users/bradlewis/repos/cowboy/build/dev/erlang/cowboy/src/cowboy_req.erl"},{line,813}]},{gleam_cowboy_native,init,2,[{file,"/Users/bradlewis/repos/cowboy/build/dev/erlang/gleam_cowboy/_gleam_artefacts/gleam_cowboy_native.erl"},{line,22}]},{cowboy_handler,execute,2,[{file,"/Users/bradlewis/repos/cowboy/build/dev/erlang/cowboy/src/cowboy_handler.erl"},{line,37}]},{cowboy_stream_h,execute,3,[{file,"/Users/bradlewis/repos/cowboy/build/dev/erlang/cowboy/src/cowboy_stream_h.erl"},{line,306}]},{cowboy_stream_h,request_process,3,[{file,"/Users/bradlewis/repos/cowboy/build/dev/erlang/cowboy/src/cowboy_stream_h.erl"},{line,295}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,241}]}]
This can be easily "fixed" by forcing cowboy
< 2.11.0.
Hello! I was going to deprecate this package as Cowboy performs much worse than Mist and Elli. What makes you want to use Cowboy specifically?
Thanks for the quick response! Nothing in particular, it was just when I saw the gleam 1.0 release I was interested in giving a http server a go. When looking at the repo here https://github.com/gleam-lang/http, I saw. cowboy mentioned and it had a very simple example in the readme which was enough for me to give it a go (compared to the mist example which is a lot more involved).
If you are planning on just deprecating it then fair enough, nothing to do here then!
Since you've done the works let's keep it for now, but I do recommend Mist over the others. I tend to use it with Wisp: https://gleam-wisp.github.io/wisp/
Sounds good to me. In the meantime I'll have a look into Mist + Wisp. Thanks!