mirror of
https://github.com/penpot/penpot.git
synced 2026-01-13 00:39:27 -05:00
Compare commits
1 Commits
develop
...
niwinz-sta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
414449b15c |
@@ -13,6 +13,7 @@
|
||||
[app.common.transit :as t]
|
||||
[app.config :as cf]
|
||||
[app.http.errors :as errors]
|
||||
[app.http.request :as http.request]
|
||||
[app.util.pointer-map :as pmap]
|
||||
[cuerdas.core :as str]
|
||||
[yetti.adapter :as yt]
|
||||
@@ -197,7 +198,8 @@
|
||||
[handler on-error]
|
||||
(fn [request]
|
||||
(try
|
||||
(handler request)
|
||||
(binding [http.request/*current* request]
|
||||
(handler request))
|
||||
(catch Throwable cause
|
||||
(on-error cause request)))))
|
||||
|
||||
|
||||
12
backend/src/app/http/request.clj
Normal file
12
backend/src/app/http/request.clj
Normal file
@@ -0,0 +1,12 @@
|
||||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns app.http.request)
|
||||
|
||||
(def ^:dynamic *current*
|
||||
"Binds to current request"
|
||||
nil)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
[app.common.time :as ct]
|
||||
[app.config :as cf]
|
||||
[app.db :as db]
|
||||
[app.http :as-alias http]
|
||||
[app.http :as http]
|
||||
[app.http.access-token :as actoken]
|
||||
[app.http.client :as-alias http.client]
|
||||
[app.http.session :as session]
|
||||
|
||||
@@ -42,10 +42,10 @@
|
||||
[:include-libraries ::sm/boolean]
|
||||
[:embed-assets ::sm/boolean]])
|
||||
|
||||
(defn stream-export-v1
|
||||
(defn- stream-export-v1
|
||||
[cfg {:keys [file-id include-libraries embed-assets] :as params}]
|
||||
(rph/stream
|
||||
(fn [_ output-stream]
|
||||
(fn [output-stream]
|
||||
(try
|
||||
(-> cfg
|
||||
(assoc ::bfc/ids #{file-id})
|
||||
@@ -57,20 +57,34 @@
|
||||
:file-id (str file-id)
|
||||
:cause cause))))))
|
||||
|
||||
(defn stream-export-v3
|
||||
(defn- stream-export-v3
|
||||
[cfg {:keys [file-id include-libraries embed-assets] :as params}]
|
||||
(rph/stream
|
||||
(fn [_ output-stream]
|
||||
(try
|
||||
(-> cfg
|
||||
(assoc ::bfc/ids #{file-id})
|
||||
(assoc ::bfc/embed-assets embed-assets)
|
||||
(assoc ::bfc/include-libraries include-libraries)
|
||||
(bf.v3/export-files! output-stream))
|
||||
(catch Throwable cause
|
||||
(l/err :hint "exception on exporting file"
|
||||
:file-id (str file-id)
|
||||
:cause cause))))))
|
||||
(letfn [(export [output-stream]
|
||||
;; (throw (ex-info "kakota" {}))
|
||||
(-> cfg
|
||||
(assoc ::bfc/ids #{file-id})
|
||||
(assoc ::bfc/embed-assets embed-assets)
|
||||
(assoc ::bfc/include-libraries include-libraries)
|
||||
(bf.v3/export-files! output-stream)))]
|
||||
|
||||
(rph/stream export)))
|
||||
|
||||
;; (with-meta {:file-id file-id
|
||||
;; :include-libraries include-libraries
|
||||
;; :embed-assets embed-assets}))))
|
||||
;; (->
|
||||
;; (rph/stream
|
||||
;; (fn [output-stream]
|
||||
;; (try
|
||||
;; (-> cfg
|
||||
;; (assoc ::bfc/ids #{file-id})
|
||||
;; (assoc ::bfc/embed-assets embed-assets)
|
||||
;; (assoc ::bfc/include-libraries include-libraries)
|
||||
;; (bf.v3/export-files! output-stream))
|
||||
;; (catch Throwable cause
|
||||
;; (l/err :hint "exception on exporting file"
|
||||
;; :file-id (str file-id)
|
||||
;; :cause cause))))))
|
||||
|
||||
(sv/defmethod ::export-binfile
|
||||
"Export a penpot file in a binary format."
|
||||
|
||||
@@ -9,7 +9,11 @@
|
||||
(:refer-clojure :exclude [with-meta])
|
||||
(:require
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.logging :as l]
|
||||
[app.config :as cf]
|
||||
[app.http :as-alias http]
|
||||
[app.http.errors :as errors]
|
||||
[app.http.request :as http.request]
|
||||
[app.rpc :as-alias rpc]
|
||||
[yetti.response :as yres]))
|
||||
|
||||
@@ -80,6 +84,15 @@
|
||||
(update response ::yres/headers assoc "cache-control" val)))))
|
||||
|
||||
(defn stream
|
||||
"A convenience allias for yetti.response/stream-body"
|
||||
[f]
|
||||
(yres/stream-body f))
|
||||
(let [request http.request/*current*]
|
||||
(yres/stream-body
|
||||
(fn [this response]
|
||||
(try
|
||||
(f response)
|
||||
(catch Throwable cause
|
||||
(binding [l/*context* (errors/request->context request)]
|
||||
(l/err :hint "exception streaming response"
|
||||
:cause cause
|
||||
::l/context (meta this)))))))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user