This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-09
Channels
- # admin-announcements (5)
- # architecture (8)
- # beginners (7)
- # boot (41)
- # braveandtrue (1)
- # cider (77)
- # clara (3)
- # cljs-dev (56)
- # cljsjs (7)
- # cljsrn (7)
- # clojure (44)
- # clojure-austin (3)
- # clojure-brasil (1)
- # clojure-hk (3)
- # clojure-russia (137)
- # clojure-spec (14)
- # clojure-uk (44)
- # clojurescript (33)
- # cloverage (3)
- # core-async (10)
- # css (1)
- # cursive (16)
- # datomic (116)
- # devcards (14)
- # emacs (1)
- # events (1)
- # funcool (2)
- # functionalprogramming (1)
- # hammock-driven-dev (1)
- # jobs-rus (124)
- # lein-figwheel (1)
- # leiningen (1)
- # liberator (4)
- # melbourne (3)
- # mount (73)
- # off-topic (3)
- # om (4)
- # om-next (15)
- # onyx (38)
- # other-languages (4)
- # perun (2)
- # proton (36)
- # protorepl (2)
- # random (1)
- # re-frame (56)
- # reagent (7)
- # specter (4)
- # testing (1)
- # untangled (13)
- # yada (18)
@malcolmsparks: you'll be happy to know I went with the vendor tag 🙂
@malcolmsparks: hate to ask malcolm but by any chance are you working on an JWT access-control example for the docs?
Hi . There are some examples in the repo under dev/ What are you trying to do? Did you see the security chapter with session security?
yea I had a look and combined what I seen in there with the sse example ending up with something like this
:access-control {:authentication-schemes [{:scheme :jwt
:yada.jwt/secret secret}]}
:methods {:get {:produces "text/event-stream”
though haven’t tested it yet
formatting for that is off it seems on my end
(defn connect []
(yada/resource {:id :server.core/connect
:summary "connect to the server"
:description "allows a user to connect to the server to begin to recieve push notifications"
;; TODO check for a valid token
:access-control {:authentication-schemes [{:scheme :jwt
:yada.jwt/secret secret}]}
:methods {:get {:produces "text/event-stream"
:response "return new messages, would better if I could use clojurescript"}}}))
Hi! I'm new to yada and trying to write a small service that can accept arbitrary (potentially binary) data via POST, e.g. to store it on disk or in a database.
Since I want to allow any mime-type for incoming data, I tried to define a yada/resource
map with a :consumes #{"*/*"}
entry.
But I get a 415 Unsupported Media Type
response when I try to send any data (with curl).
@cberg: The best approach, I assume from writing out the complete resource model, is that if you want to except all types it is best to not include the :consumes #{}
leaving room for a more agnostic approach in which it decides the mime-type on the fly based in the data being consumed
$ curl -i -X POST -d "foo" -H "Content-Type: text/plain"
HTTP/1.1 415 Unsupported Media Type
Content-Length: 644
Content-Type: application/json
Server: Aleph/0.4.1
Connection: Keep-Alive
Date: Tue, 09 Aug 2016 23:34:27 GMT
{"status":415,"message":"Unsupported Media Type","id":"7132f90f-777a-488f-8d86-ff8b661d5571","error":{"error":"clojure.lang.ExceptionInfo: Unsupported Media Type {:status 415, :message \"Method does not declare that it consumes this content-type\", :consumes #{}, :content-type <#C0702A7SB>.media_type.MediaTypeMap{:name \"text/plain\", :type \"text\", :subtype \"plain\", :parameters {}, :quality 1.0}}","data":"{:status 415, :message \"Method does not declare that it consumes this content-type\", :consumes #{}, :content-type <#C0702A7SB>.media_type.MediaTypeMap{:name \"text/plain\", :type \"text\", :subtype \"plain\", :parameters {}, :quality 1.0}}”}}
let me consult the resource model for a second I believe I have noted this case down
hmm it should work, though I am just curious are you intentionally returning the entire ctx for testing/practice purposes? I’d recommend (:body ctx)
. what kind of content are you trying to consume? you defined the content as text/plain
but it found application/json
@cberg: figured out what you are looking for :consumes “*”
same as :consumes #{“*”}
with the first being preferred for a single type. Though it is usually best to decide up front the mime-types you want to consume, see http://www.iana.org/assignments/media-types/media-types.xhtml for a list of them