lack-middleware-http-methods
May 15, 2024 ยท View on GitHub
Responds with 501: Not Implemented when the request method is unsupported by the server
Usage
Wrap app:
(funcall lack/middleware/http-methods:*lack-middleware-http-methods*
*app*
:methods '(:GET :HEAD :POST :PUT :PATCH :DELETE :OPTIONS))
Lack Builder:
(lack:builder
(:http-methods :methods '(:GET :HEAD :POST :PUT :PATCH :DELETE :OPTIONS))
*app*)
Custom handler as list:
(lack:builder
(:http-methods :methods '(:GET :HEAD :POST :PUT :PATCH :DELETE :OPTIONS)
:on-unknown `(501
(:content-type "application/json"
:content-length 32)
("{\"http_error\":\"not_implemented\"}")))
*app*)
Custom handler as function:
(lack:builder
(:http-methods :methods '(:GET :HEAD :POST :PUT :PATCH :DELETE :OPTIONS)
:on-unknown #'(lambda (env)
(declare (ignore env))
`(501
(:content-type "application/json"
:content-length 32)
("{\"http_error\":\"not_implemented\"}"))))
*app*)
Methods HEAD and GET are configured by default as these are required to
be supported by HTTP servers, but can be provided in the methods parameter.
Development
Run tests:
(asdf:test-system :foo.lisp.lack-middleware-http-methods)
Installation
Not in Quicklisp, so clone to "local-projects/".
Author
- John Newton (jnewton@lisplizards.dev)
Copyright
Copyright (c) 2024 John Newton
License
Apache-2.0