-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.clj
30 lines (26 loc) · 1.01 KB
/
core.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(ns vuk.core
(:require [vuk.request :as request]
[vuk.response :as response]))
(defn finger
"The main function to look up an 'acct'."
([acct] (finger acct {}))
([acct options]
(request/lookup acct options)))
(defn link
; REVIEW: i'm assuming that rels are supposed to be unique.
; if there can be multiple of the same rel, this should be changed
; to return an array of matching rels
"Extracts a link from a finger result based on its 'rel'."
[result rel]
(->> result :links (filter #(= (:rel %) rel)) first))
(defn represent
"Represents the user as either JSON or XML."
[user & {format :as, :or {format :json}}]
(case format
(:json :JSON "json" "JSON") (response/represent-json user)
(:xml :XML "xml" "XML") (response/represent-xml user)))
(def host-meta
"Generates host-meta XML from an URL template. It's passed as-is.
Common template is https://example.com/.well-known/webfinger?resource={uri}
This is expected to live at .well-known/host-meta"
response/host-meta)