This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-24
Channels
- # aws-lambda (1)
- # beginners (99)
- # boot (46)
- # cider (8)
- # cljs-dev (20)
- # cljsrn (37)
- # clojure (189)
- # clojure-dev (22)
- # clojure-dusseldorf (28)
- # clojure-italy (1)
- # clojure-russia (28)
- # clojure-spec (10)
- # clojure-uk (33)
- # clojurebridge (1)
- # clojurescript (64)
- # core-matrix (2)
- # css (3)
- # cursive (3)
- # datascript (34)
- # datomic (101)
- # defnpodcast (2)
- # dirac (5)
- # events (1)
- # funcool (3)
- # ldnclj (1)
- # lumo (11)
- # mount (1)
- # off-topic (95)
- # pedestal (2)
- # perun (10)
- # re-frame (3)
- # reagent (6)
- # ring-swagger (4)
- # specter (102)
- # test-check (1)
- # untangled (1)
- # vim (8)
- # yada (17)
I’ve asked it before but I’ll try again: can anyone give an example of this key in the Schema? What is it for exactly? https://github.com/juxt/yada/blob/master/src/yada/schema.clj#L50
@dominicm I think so too. Say I want to mandate a header like “x-my-custom-header”, what should the resource parameter entry look like?
This gives me a 500:
(defresource new-echo-resource []
{:methods
{:post
{:parameters {:header {“x-my-custom-header” String}}
:response (fn [ctx]
{:res (-> ctx :parameters)})}}})
Maybe I’m still missing something here: https://www.dropbox.com/s/64plf1lmwxf5cfw/Screenshot%202017-04-24%2010.57.05.png?dl=0
I'm not saying the tests definitely pass 😉. Just that this is the intended usage afaict.
Yeah, the required-key doesn’t yield the 500, but maybe the header is filtered somewhere else before it arrives at the resource
In schema, if you want a string key to be required, you must wrap in (s/required-key "x-my...")
Keywords get special treatment
Ah ok. Any idea why I still get the {:status 400, :errors ([:header {:error {"X-Foo" missing-required-key}}])}
when I provide the header in a REST client?
I think I found it. I have to provide the header name in lowercase in the Schema, because probably somewhere else in the interceptor chain every header name is lowercased.
Can I get class-path-resource
to not respond on directories? E.g. a request to /js
now responds with some text that represents a directory listing of /public/js
.
@borkdude ah, thanks for resolving that itch for me ❤️. That's not brilliant I suppose.
(yada/response-for
(-> (yada/as-resource (io/resource (.getPath (java.io.File. "public/js")))))
:get)
;;=>
{:status 200,
:body "app.cljs.edn\napp.js\napp.out\n"}
It’s probably due to this one: https://github.com/juxt/yada/blob/master/src/yada/resources/file_resource.clj#L219