This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-30
Channels
- # babashka (46)
- # beginners (234)
- # bristol-clojurians (4)
- # cider (7)
- # clj-kondo (39)
- # cljdoc (8)
- # cljs-dev (10)
- # cljsjs (10)
- # cljsrn (24)
- # clojure (84)
- # clojure-brasil (7)
- # clojure-europe (12)
- # clojure-germany (4)
- # clojure-italy (3)
- # clojure-nl (41)
- # clojure-spec (17)
- # clojure-uk (66)
- # clojurescript (64)
- # conjure (161)
- # cursive (12)
- # data-science (45)
- # datomic (20)
- # devops (11)
- # docker (2)
- # duct (9)
- # events (7)
- # figwheel (1)
- # figwheel-main (20)
- # fulcro (32)
- # graalvm (5)
- # helix (82)
- # jackdaw (9)
- # jobs-discuss (19)
- # kaocha (11)
- # local-first-clojure (1)
- # malli (6)
- # meander (3)
- # nrepl (12)
- # off-topic (2)
- # other-lisps (15)
- # pathom (14)
- # rdf (6)
- # re-frame (8)
- # reactive (1)
- # reagent (5)
- # reitit (4)
- # rum (3)
- # shadow-cljs (77)
- # spacemacs (3)
- # sql (9)
- # test-check (31)
- # tools-deps (13)
- # vim (62)
- # xtdb (18)
@manutter51 Thanks! I will look into it. 🙂
Anyone using reitit with pedestal + coercions? I’m not getting any exceptions when my route’s params type’s mismatch
I have an endpoint that downloads an excel file. For testing purposes, here is the handler:
(defn download-handler [_request]
(let [file "book.xlsx"]
(-> (file-response file)
(content-type "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
(header "Content-Disposition" (str "attachment;filename=" (gensym "book") ".xlsx")))))
This is invoked with the following router and handler:
(def router
(ring/router
[["/download" {:get download-handler
:summary "downloads an xlsx file"
:swagger {:produces ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"]}}]
["" {:no-doc true}
["/swagger.json"
{:get {:no-doc true
:swagger {:info {:title "Download API"}
:basePath "/"}
:handler (swagger/create-swagger-handler)}}]
["/api-docs*" {:get (swagger-ui/create-swagger-ui-handler {:url "/swagger.json"})}]]]
{:data {:coercion rc-spec/coercion
:middleware [params/wrap-params
middleware/wrap-format
parameters/parameters-middleware
muuntaja/format-negotiate-middleware
muuntaja/format-response-middleware
exception/exception-middleware
muuntaja/format-request-middleware
coercion/coerce-response-middleware
coercion/coerce-request-middleware
multipart/multipart-middleware]}}))
(def handler
(ring/ring-handler
router
(constantly (not-found "Not found"))))
When I invoked the download endpoint directly (just putting http://localhost:3000/download) it works as expected in the browser. When I use the generated Swagger UI I get the "Try it out!" button for the endpoint, which I press. It then gives me a link (e.g. <blob:http://localhost:3000/50986c29-ba76-4acb-a022-c121aca29157|Download book6651.xlsx>). When I click the link and download the file it somehow changes the file. The file is larger and is not openable by Excel. Any idea what's going on or how I fix it?If anyone cares to check this out, I've created a spike solution at https://github.com/markbastian/download-xlsx. I've added both lein and tools.deps support.