summaryrefslogtreecommitdiff
path: root/neocities
diff options
context:
space:
mode:
Diffstat (limited to 'neocities')
-rw-r--r--neocities/api.scm6
-rw-r--r--neocities/requests.scm13
2 files changed, 10 insertions, 9 deletions
diff --git a/neocities/api.scm b/neocities/api.scm
index 5e3d2d0..a2017a7 100644
--- a/neocities/api.scm
+++ b/neocities/api.scm
@@ -61,11 +61,14 @@
(throw 'neocities "Authentication scheme not supported"))))
(define-record-type <neocities-api>
- (make-neocities-api hostname auth)
+ (_make-neocities-api hostname port auth)
neocities-api?
(hostname neocities-api-hostname)
+ (port neocities-api-port)
(auth neocities-api-auth neocities-api-auth-set!))
+(define* (make-neocities-api hostname auth #:optional port)
+ (_make-neocities-api hostname port auth))
(define* (neocities-delete api files)
@@ -73,6 +76,7 @@
(throw 'neocities "files to delete must be a list"))
(let ((url (neocities-url "delete"
+ #:port (neocities-api-port api)
#:hostname (neocities-api-hostname api)
#:querystring `(("files" . ,files)))))
(neocities-request
diff --git a/neocities/requests.scm b/neocities/requests.scm
index 094b7bf..b6a74ff 100644
--- a/neocities/requests.scm
+++ b/neocities/requests.scm
@@ -43,7 +43,9 @@
encode-multipart-body))
(define* (neocities-url endpoint #:key (querystring '())
- (hostname #f))
+ (hostname #f)
+ (insecure #f)
+ (port #f))
(define (encode-querystring querystring)
(string-join
(map (lambda (x)
@@ -59,17 +61,12 @@
querystring)
"&"))
- ;; This is for testing locally :)
- #;(build-uri 'http #:host "localhost"
- #:port 1234
- #:path (string-append "/api/" endpoint)
- #:query (encode-querystring querystring))
- (build-uri 'https
+ (build-uri (if insecure 'http 'https)
#:host (or hostname "neocities.org")
+ #:port port
#:path (string-append "/api/" endpoint)
#:query (encode-querystring querystring)))
-
(define (encode-multipart-body files)
"files is an alist with the filename and destination"