♻️ Refactor backend.

Move from custom vertx to jetty9.
This commit is contained in:
Andrey Antukh 2020-05-14 13:49:11 +02:00 committed by Alonso Torres
parent 1639e15975
commit 5a03c13731
82 changed files with 1763 additions and 4667 deletions

View file

@ -39,7 +39,8 @@
ptk/UpdateEvent
(update [_ state]
(let [sid (:session-id state)
url (ws/url (str "/notifications/" file-id "/" sid))]
url (ws/url "/ws/notifications" {:file-id file-id
:session-id sid})]
(assoc-in state [:ws file-id] (ws/open url))))
ptk/WatchEvent

View file

@ -35,13 +35,15 @@
[{:keys [body headers auth method query url response-type]
:or {auth true response-type :text}}]
(let [headers (merge {"Accept" "application/transit+json,*/*"}
default-headers
(when (map? body) default-headers)
headers)
request {:method method
:url url
:headers headers
:query query
:body (when (not= :get method) (t/encode body))}
:body (if (map? body)
(t/encode body)
body)}
options {:response-type response-type
:credentials? auth}]
(http/send! request options)))

View file

@ -25,13 +25,17 @@
(-close [_] "close websocket"))
(defn url
[path]
(let [url (.parse Uri cfg/url)]
(.setPath url path)
(if (= (.getScheme url) "http")
(.setScheme url "ws")
(.setScheme url "wss"))
(.toString url)))
([path] (url path {}))
([path params]
(let [uri (.parse Uri cfg/url)]
(.setPath uri path)
(if (= (.getScheme uri) "http")
(.setScheme uri "ws")
(.setScheme uri "wss"))
(run! (fn [[k v]]
(.setParameterValue uri (name k) (str v)))
params)
(.toString uri))))
(defn open
[uri]