Exploring Janet and the httpf web framework

12 points by veqq


veqq

I wrote little tutorials for the Osprey and Joy web frameworks, I'll link to this from there!

janet-html is more permissive/comfortable for hiccup, but it's marginal.

christine

I've been thinking recently about how using Janet's disasm to do introspection/analysis. For example, in the route they give:

(defn my-index-route
  {:path "/" ...}
  [request post-data]
  (def body [:html [:body [:h1 "Welcome to httpf"]
                    [:p "I am glad you are here!"]]])
  (setdyn :response-code 201) # setdyn is used to specify the HTTP Response code
  body)

You could imagine that the httpf library understands that the body is to be interpreted as an HTML tree, and partially evaluates it ahead-of-time, to produce something like

(defn my-index-route
  {:path "/" ...}
  [request post-data]
  (setdyn :response-code 201) # setdyn is used to specify the HTTP Response code
  "<!DOCTYPE html><html><body><h1>Welcome to httpf</h1><p>I am glad you are here!</p></body></html>")

(if there was any dynamically varying content, it could be interpolated)