mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-07 02:33:39 +02:00
Login → Album List → Album Detail
This commit is contained in:
parent
eb59e97e96
commit
9ca116ee72
3 changed files with 64 additions and 13 deletions
29
src/airsonic_ui/api.cljs
Normal file
29
src/airsonic_ui/api.cljs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
(ns airsonic-ui.api
|
||||
(:require [clojure.string :as string]
|
||||
[airsonic-ui.config :as config]))
|
||||
|
||||
(defn ^:private uri-escape [s]
|
||||
(js/encodeURIComponent s))
|
||||
|
||||
(defn url
|
||||
"Returns an absolute url to an API endpoint"
|
||||
[endpoint params]
|
||||
(let [query (->> (assoc params
|
||||
:f "json"
|
||||
:c "airsonic-ui-cljs"
|
||||
:v "1.15.0")
|
||||
(map (fn [[k v]]
|
||||
(str (uri-escape (name k)) "=" (uri-escape v))))
|
||||
(string/join "&"))]
|
||||
(str config/server "/rest/" endpoint "?" query)))
|
||||
|
||||
(defn ^:private api-error?
|
||||
"We need to look at the message body because the subsonic api always responds
|
||||
with status 200"
|
||||
[response]
|
||||
(= "failed" (-> response :subsonic-response :status)))
|
||||
|
||||
(defn ^:private error-message
|
||||
[response]
|
||||
(let [{:keys [code message]} (-> response :subsonic-response :error)]
|
||||
(str "Code " code ": " message)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue