1
0
Fork 0

Compare commits

..

No commits in common. '8c87cf5b37aa88405c6e12e4c543b9475c76145b' and '05b876bea755d3097d52695576e171b27b778f72' have entirely different histories.

  1. 2
      .gitignore
  2. 2
      ritherdon-rest.asd
  3. 5
      src/package.lisp
  4. 35
      src/ritherdon-rest.lisp

2
.gitignore vendored

@ -17,4 +17,4 @@
*.wx64fsl
*.wx32fsl
*.directory
/.directory

2
ritherdon-rest.asd

@ -8,7 +8,6 @@
:version "0.0.1"
:serial t
:in-order-to ((test-op (test-op "ritherdon-rest/tests")))
:depends-on (:drakma :cl-json)
:pathname "src/"
:components ((:file "package")
(:file "ritherdon-rest")))
@ -20,6 +19,7 @@
:author "craig@craigoates.net"
:license "MIT"
:version "0.0.1"
:serial t
:depends-on (:ritherdon-rest :fiveam)
:perform (test-op (o s)
(uiop:symbol-call :fiveam :run!

5
src/package.lisp

@ -1,7 +1,4 @@
;;;; package.lisp
(defpackage #:ritherdon-rest
(:use #:cl #:drakma :cl-json)
(:export :parse-request
:decode-json)) ; Part of cl-json, getting errors without
; it in SLIME.
(:use #:cl))

35
src/ritherdon-rest.lisp

@ -1,37 +1,6 @@
;;;; ritherdon-rest.lisp
;;; A collection of functions to aid in the make
;;; http-requests to the Ritherdon REST API. This project is help me
;;; learn Common Lisp. So, there is not much emphasis on being too
;;; strict on best practices and defensive coding.
;;; NOTE: The Ritherdon REST API is part of an art exhibition at time
;;; of writing (29/06/2021). You will need to check if the server is
;;; still running if you want to run this code.
(in-package #:ritherdon-rest)
;; All the data provided by the Ritherdon REST API is in JSON. Becuase
;; of this I can set the `TEXT-CONTENT-TYPE' to JSON and keep it like
;; that until further notice.
(setq drakma:*text-content-types* (cons '("application" . "json")
drakma:*text-content-types*))
;; The Base URL which you build all your HTTP Requests on. You will
;; need to refer back to http://ritherdon.abbether.net/api/ui/ for the
;; full set of URL's.
(defvar *base-url* "http://ritherdon.abbether.net/api")
;; The http-request is actually 'drakma:http-request'. I've done it
;; this way to highlight the feature. It is the same as what you've
;; used in the past with C# and 'using static' statements. So, not
;; much to go into here apart from highlighting it's a thing in Common
;; Lisp, too.
(defun make-request (query)
(http-request (concatenate 'string *base-url* query)))
;; Same as the drakma example above. It can read as
;; 'cl-json:decode-json-from-string' but omitted the 'cl-json'
;; bit. You will find all package declarations in /src/package.lisp'.
(defun parse-request (query)
(decode-json-from-string(make-request query)))
(defun hello ()
(print "The system is up and running."))