diff --git a/common.lisp b/common.lisp index 3a1b237..cac71ba 100644 --- a/common.lisp +++ b/common.lisp @@ -1,27 +1,10 @@ (in-package #:snooze-common) - -;;; Verbs -;;; -;;; "Sending" and "Receiving" are always from the server's -;;; perspective. Hence GET is "sending to client" and POST and PUT are -;;; "receiving from client". -;;; -(defpackage :snooze-verbs (:use) (:export #:http-verb #:get #:post #:put #:delete - #:content-verb - #:receiving-verb - #:sending-verb)) - -(cl:defclass snooze-verbs:http-verb () ()) -(cl:defclass snooze-verbs:delete (snooze-verbs:http-verb) ()) -(cl:defclass snooze-verbs:content-verb (snooze-verbs:http-verb) ()) -(cl:defclass snooze-verbs:receiving-verb (snooze-verbs:content-verb) ()) -(cl:defclass snooze-verbs:sending-verb (snooze-verbs:content-verb) ()) -(cl:defclass snooze-verbs:post (snooze-verbs:receiving-verb) ()) -(cl:defclass snooze-verbs:put (snooze-verbs:receiving-verb) ()) -(cl:defclass snooze-verbs:get (snooze-verbs:sending-verb) ()) - -(defun destructive-p (verb) (typep verb 'snooze-verbs:receiving-verb)) + +(defun destructive-p (verb) + "Returns true if it is possible for a request with the http VERB to modify +the server state." + (typep verb 'snooze-verbs:receiving-verb)) ;;; Content-types diff --git a/http.lisp b/http.lisp new file mode 100644 index 0000000..1525c87 --- /dev/null +++ b/http.lisp @@ -0,0 +1,26 @@ +;;; HTTP Verbs + +(defpackage #:snooze-verbs + (:use) + (:export #:http-verb + #:get + #:patch + #:post + #:put + #:delete + #:content-verb + #:receiving-verb + #:sending-verb) + (:documentation "The taxonomy of HTTP verbs used by snooze. In addition to the verbs themselves it groups verbs in content, sending and receiving verbs. Sending and Receiving are always from the server's perspective. Hence GET is sending to client and POST and PUT are receiving from client.")) + +(cl:defclass snooze-verbs:http-verb () ()) +(cl:defclass snooze-verbs:delete (snooze-verbs:http-verb) ()) +(cl:defclass snooze-verbs:content-verb (snooze-verbs:http-verb) ()) +(cl:defclass snooze-verbs:receiving-verb (snooze-verbs:content-verb) () + (:documentation "Indicates that the request carries information from the client to the server.")) +(cl:defclass snooze-verbs:sending-verb (snooze-verbs:content-verb) () + (:documentation "Indicates that the request is asking information from the server.")) +(cl:defclass snooze-verbs:patch (snooze-verbs:receiving-verb) ()) +(cl:defclass snooze-verbs:post (snooze-verbs:receiving-verb) ()) +(cl:defclass snooze-verbs:put (snooze-verbs:receiving-verb) ()) +(cl:defclass snooze-verbs:get (snooze-verbs:sending-verb) ()) diff --git a/snooze.asd b/snooze.asd index 79a43c5..aead521 100644 --- a/snooze.asd +++ b/snooze.asd @@ -8,6 +8,7 @@ :components ((:file "package") (:file "constants") (:file "safe-simple-read") + (:file "http") (:file "common") (:file "api")))