From 18dd5aface1c3f21a3c2c1d5e35a59279212a4f2 Mon Sep 17 00:00:00 2001 From: colin Date: Sat, 17 Aug 2024 08:46:04 -0700 Subject: Add check-request-compliance method and get-header function --- src/protocol.lisp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/protocol.lisp') diff --git a/src/protocol.lisp b/src/protocol.lisp index f94364a..74019b1 100644 --- a/src/protocol.lisp +++ b/src/protocol.lisp @@ -101,6 +101,17 @@ that the request has insufficient permissions to evoke the endpoint handler. ")) ;;; HANDLER PROTOCOL +(defgeneric check-request-compliance (endpoint-instance-class) + (:documentation "This function is called before instances the endpoint class are +created; This occurrs before the HTTP request's body has been +read. All request headers are available for inspection. + +This is meant to enforce higher-level or server-wide policies, such as +on the size of request bodies.") + (:method ((epclass symbol)) + (check-request-compliance (find-class epclass))) + (:method ((epclass t)))) + (defgeneric authenticate (endpoint) (:documentation "Returns a boolean. Any protected endpoint should implement this. Called before handling, should be used to supply @@ -161,6 +172,11 @@ AUTHORIZE while handling endpoint-class instance EP." "Returns the cookie with name NAME the actively" (http:cookie-in name)) +(defun get-header (name) + "Returns the string value of the header named NAME, which can be a +string or keyword." + (http:header-in* name)) + (define-condition request-error (error) ((content :reader error-content :initarg :content :initform "Bad Request") (mimetype :reader error-content-mimetype :initarg :mimetype :initform "text/plain") -- cgit v1.2.3