This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-19
Channels
- # admin-announcements (8)
- # beginners (90)
- # boot (69)
- # bristol-clojurians (3)
- # cider (32)
- # cljs-dev (2)
- # cljsrn (22)
- # clojure (45)
- # clojure-art (2)
- # clojure-poland (102)
- # clojure-russia (91)
- # clojurescript (38)
- # cursive (27)
- # datomic (45)
- # devcards (7)
- # emacs (45)
- # gorilla (25)
- # hoplon (3)
- # jobs (1)
- # ldnclj (7)
- # off-topic (4)
- # om (176)
- # onyx (3)
- # portland-or (7)
- # re-frame (12)
- # reagent (64)
- # yada (26)
@malcolmsparks: do you have an example on how to use multipart/form-data?
beginner question : can we control the response type headers ? For instance, if I use :
(yada (fn [ctx]
"Hello"))
I get a proper answer, but with application/octet-stream
, while I would like application/json
I am trying that now :
(yada (fn [ctx]
{:status 202
:media-type "text/html"
:body "Hello"}))
But I get a 500 :
#error {
:cause "Attempt to call render-map without a media-type: {:media-type <#C0702A7SB>.media-type[application/octet-stream;q=1.0]}"
:data {:representation {:media-type <#C0702A7SB>.media-type[application/octet-stream;q=1.0]}}
:via
Even that (from the user manual) fails for me :
(yada
(fn [ctx]
(case (get-in ctx [:response :representation :language])
"zh-ch" "你好世界!\n"
"en" "Hello World!\n"))
:representations [{:media-type "text/plain"
:language #{"en" "zh-ch"}
:charset "UTF-8"}
{:media-type "text/plain"
:language "zh-ch"
:charset "Shift_JIS;q=0.9"}])
With :
#error {
:cause "Wrong number of args (3) passed to: core/handler"
:via
[{:type clojure.lang.Compiler$CompilerException
and in order to provide for instance both application/json and application/edn you can provide representations in the yada options
(yada/yada your-fn {:representations [{:media-type "application/json"
:charset "UTF-8"}
{:media-type "application/edn"
:charset "UTF-8"}]}
imre: this resource shows the headers you need - https://www.refheap.com/37a14e7936326bb7d592304b2
@stijn: you're a bit ahead of me, but the full yada upload story is very close now, it includes async upload of byte-streams, multipart handling and you will be able to specify your own strategies for handling uploads (memory, off-heap, disk, etc..)
I've also fixes an old issue (#15) by allowing you to specify consumes in swagger
I've got a new example in the works (selfie) that shows how to do this, and I'll be updating the user-manual too in due course
@malcolmsparks that sounds promising