Closed neezer closed 2 weeks ago
Ahh, it was an environment issue.
I need to call httpf/add-bindings-as-routes
outside of main
:
(import spork/httpf)
(def server (httpf/server))
(defn home
"The homepage"
{:path "/"}
[&]
@[[:h1 "Hello, world!"]])
(httpf/add-bindings-as-routes server)
(defn main [&]
(httpf/listen server))
I may be a dum-dum, but why does examples/httpf-simple.janet cease to work if you start the server inside
main
?Eg.
The above gives me a 404 error when requesting
/
. I'm guessing it's becausehttpf/add-bindings-as-routes
doesn't see thehome
function despite having the:path
metadata, but I can't figure out why.Any help would be appreciated. The existing example starts the HTTP server when running
jpm build
orjudge
, which is neither expected nor helpful, thus my attempts to wrap it insidemain
.