Hacker News new | ask | show | jobs
by 147 2224 days ago
Not OP but for me, I wanted to write http server applications and I was put off by having to specify the http response status messages and timestamps. I'm wondering why something slightly higher level isn't built into the standard lib.
2 comments

You don’t have to specify those things yourself unless you want to manually construct a response struct. There are helpers like response/xexpr and response/output that construct responses for you.

This article might help: https://defn.io/2020/02/12/racket-web-server-guide/

But if I wanted to say return a 404 I don't want to have to specify "Not Found" along with it every time.
As of a couple releases ago, the message gets set according to the status code so this code would behave as expected:

    (response/xexpr #:code 404 '(h1 "Not Found"))
These days, response status messages are automatically inferred: https://docs.racket-lang.org/web-server/http.html?q=response...
Thanks! I’m gonna give racket another spin now.