Compare commits
No commits in common. '8c87cf5b37aa88405c6e12e4c543b9475c76145b' and '05b876bea755d3097d52695576e171b27b778f72' have entirely different histories.
8c87cf5b37
...
05b876bea7
4 changed files with 5 additions and 39 deletions
@ -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)) |
||||
|
@ -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.")) |
||||
|
Reference in new issue