summaryrefslogtreecommitdiff
path: root/src/transport.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport.lisp')
-rw-r--r--src/transport.lisp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/transport.lisp b/src/transport.lisp
index 6906e6d..12e09f4 100644
--- a/src/transport.lisp
+++ b/src/transport.lisp
@@ -6,13 +6,20 @@
6 (:import-from :cl+ssl) 6 (:import-from :cl+ssl)
7 (:import-from :dex) 7 (:import-from :dex)
8 (:import-from :log) 8 (:import-from :log)
9 (:import-from :serapeum :->)
9 (:import-from :state :base-uri) 10 (:import-from :state :base-uri)
10 (:import-from :ukkoclot/src/serializing :fixup-args :parse-value) 11 (:import-from :ukkoclot/src/serializing :fixup-args :parse-value)
11 (:local-nicknames 12 (:local-nicknames
12 (:jzon :com.inuoe.jzon)) 13 (:jzon :com.inuoe.jzon))
13 (:export :do-call)) 14 (:export :do-call :http-method))
14(in-package :ukkoclot/src/transport) 15(in-package :ukkoclot/src/transport)
15 16
17;; Yes I know there are more, these are all I care about though
18(deftype http-method ()
19 '(member :GET :POST))
20
21;; TODO: Better type for the list, it's an alist of string to t
22(-> req (string http-method list) (or string null))
16(defun req (uri method content) 23(defun req (uri method content)
17 "Wrapper function for making a request." 24 "Wrapper function for making a request."
18 (let ((retrier (dex:retry-request 5 :interval 1)) 25 (let ((retrier (dex:retry-request 5 :interval 1))
@@ -25,6 +32,8 @@
25 (dex:http-request-failed (e) (funcall retrier e)) 32 (dex:http-request-failed (e) (funcall retrier e))
26 (cl+ssl::ssl-error (e) (funcall retrier e))))) 33 (cl+ssl::ssl-error (e) (funcall retrier e)))))
27 34
35;; TODO: (alist string t)
36(-> do-call% (http-method string t list) t)
28(defun do-call% (method uri out-type args-encoded) 37(defun do-call% (method uri out-type args-encoded)
29 "Internal function with the arguments already encoded. 38 "Internal function with the arguments already encoded.
30 39
@@ -47,6 +56,8 @@ See `do-call'."
47 (error "TG error ~A: ~A ~:A" 56 (error "TG error ~A: ~A ~:A"
48 error-code description parameters))))))) 57 error-code description parameters)))))))
49 58
59;; TODO: (alist t t)
60(-> do-call (http-method string t list) t)
50(defun do-call (method path out-type args) 61(defun do-call (method path out-type args)
51 "Perform a HTTP call." 62 "Perform a HTTP call."
52 (let ((uri (concatenate 'string (base-uri) path)) 63 (let ((uri (concatenate 'string (base-uri) path))