Skip to content

Added external-format support to ipfs-call #15

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions main.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,21 @@
;; only necessary if yours deviates from the
;; default path. only used for #'pubsub-*


(defparameter *external-format* drakma:*drakma-default-external-format*
"Allows control of the external format used when reading from ipfs. The
default, borrowed from drakma, is :latin-1. :utf-8 will cause the the
resource to be treated as unicode UTF 8. A list of all available formats
can be found at https://edicl.github.io/flexi-streams/#external-formats")

;; —————————————————————————————————————
;; BASE

;; STRING LIST [:LIST :BOOLEAN :SYMBOL] → STRING | ALIST | (NIL STRING)
(defun ipfs-call (call arguments &key (parameters nil) (want-stream nil)
(method :POST))
(method :POST) (external-format *external-format*))
"Make an IPFS HTTP API call. Quite commonly used.
Some calls return strings/raw data, and others return JSON.
When strings/arbitrary data are recieved, they're returned verbatim.
When strings/arbitrary data are received, they're returned verbatim.
But, when JSON is returned, it is parsed into a hashtable.
If the JSON is 'error JSON', I.E., it signals that an error has been
recieved, two values are returned: NIL and the string-error-message."
Expand All @@ -36,6 +40,7 @@
:method method
:url-encoder #'ipfs::url-encode
:parameters parameters
:external-format-in external-format
:want-stream want-stream))))
(if want-stream
(car result)
Expand Down
3 changes: 2 additions & 1 deletion package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,5 @@
;; version calls
:version
:version-deps
#:with-files-write))
#:with-files-write
#:*external-format*))