Wrap app:
(funcall lack/middleware/errors:*lack-middleware-errors*
*app*
:app (foo.lisp.vinland/errors-app/simple/basic:make-app
:root demo-app/config:*static-errors-directory*
:static-file-types demo-app/http-error:*static-file-types*
:handlers demo-app/http-error:*http-errors*)
:intercept (lambda (condition)
(declare (type error condition))
(typecase condition
(foo.lisp.http-response:http-error (slot-value condition 'foo.lisp.http-response:status-code))
(foo.lisp.raven:no-route-error 404))))
Lack Builder:
(lack:builder
(:errors :app (foo.lisp.vinland/errors-app/simple/basic:make-app
:root demo-app/config:*static-errors-directory*
:static-file-types demo-app/http-error:*static-file-types*
:handlers demo-app/http-error:*http-errors*)
:intercept (lambda (condition)
(declare (type error condition))
(typecase condition
(foo.lisp.http-response:http-error (slot-value condition 'foo.lisp.http-response:status-code))
(foo.lisp.raven:no-route-error 404))))
*app*)
INTERCEPT
: required; function that takes an error condition and returns an HTTP error status response code; a NIL return value results in response code 500APP
: required; function that takes an ENV list and returns a response (a Clack application); before forwarding to the errors app, the middleware re-writes the path-info to the status code returned by functionINTERCEPT
and re-writes the request-method to GET
Run tests:
(asdf:test-system :foo.lisp.lack-middleware-errors)
Not in Quicklisp, so clone to "local-projects/".
- John Newton (jnewton@lisplizards.dev)
Copyright (c) 2024 John Newton
Apache-2.0