joy-framework / joy

A full stack web framework written in janet

Home Page:https://joy.swlkr.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Returning alternate status (such as 401) does not use the layout

LeviSchuck opened this issue · comments

commented

At present if I return

{:status 401 :body [:h1 "no can do"]}

from a handler, it fails during the middleware stuff where it's trying to merge things.

To get around this, I had to make my own function that evaluates the layout manually.

(defn not-authorized [request body]
  (merge
    (template/app-layout {:request request :body body})
    @{
    :status 401
    }))

I think it's safe to say that if the body is a list and not bytes?, and there's no content type header, that the layout middleware can be used.