This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-17
Channels
- # aleph (3)
- # bangalore-clj (2)
- # beginners (76)
- # boot (37)
- # braid-chat (7)
- # business (1)
- # clara (1)
- # cljsrn (45)
- # clojure (36)
- # clojure-android (1)
- # clojure-austin (2)
- # clojure-dusseldorf (4)
- # clojure-spec (2)
- # clojure-uk (2)
- # clojurebridge-ams (4)
- # clojurescript (79)
- # clr (1)
- # community-development (5)
- # core-async (1)
- # cursive (4)
- # data-science (1)
- # funcool (3)
- # hoplon (3)
- # om (107)
- # om-next (6)
- # other-lisps (1)
- # overtone (1)
- # planck (2)
- # reagent (24)
- # rum (1)
- # specter (7)
- # yada (46)
Hey Yada channel, trying to serve some static files with yada 1.1.33
with the follow code
clojure.lang.ExceptionInfo: Cannot turn resource-model into resource, because it doesn't conform to a resource-model schema {:resource-model nil, :error {:methods missing-required-key}}
@iwillig That should work.
Does out
exist?
as-resource
behaves differently if the file given is a file or directory. I wonder if the fact it may not exist is the problem
No. It doesn't. What does (.isDirectory (io/file "out"))
report?
it works for me on 1.1.33 (that's never a satisfactory answer, I know, so I wonder what is going on in your situation @iwillig )
could you have overridden ResourceCoercion for java.io.file ?
See https://github.com/juxt/yada/blob/master/src/yada/resources/file_resource.clj
{:path-info? true,
:produces
[{:media-type
{:name "text/plain",
:type "text",
:subtype "plain",
:parameters {},
:quality 1.0}}
{:media-type
{:name "text/html",
:type "text",
:subtype "html",
:parameters {},
:quality 1.0}}],
:error-interceptor-chain
[#function[yada.security/access-control-headers]
#function[yada.interceptors/create-response]
#function[yada.interceptors/logging]
#function[yada.interceptors/return]],
:methods
{:get
{:response
#function[yada.resources.file-resource/eval42586/new-directory-resource--42591/fn--42595/fn--42597]}},
:interceptor-chain
[#function[yada.interceptors/available?]
#function[yada.interceptors/known-method?]
#function[yada.interceptors/uri-too-long?]
#function[yada.interceptors/TRACE]
#function[yada.interceptors/method-allowed?]
#function[yada.interceptors/parse-parameters]
#function[yada.interceptors/capture-proxy-headers]
#function[yada.security/authenticate]
#function[yada.interceptors/get-properties]
#function[yada.security/authorize]
#function[yada.interceptors/process-request-body]
#function[yada.interceptors/check-modification-time]
#function[yada.interceptors/select-representation]
#function[yada.interceptors/if-match]
#function[yada.interceptors/if-none-match]
#function[yada.interceptors/invoke-method]
#function[yada.interceptors/get-new-properties]
#function[yada.interceptors/compute-etag]
#function[yada.security/access-control-headers]
#function[yada.security/security-headers]
#function[yada.interceptors/create-response]
#function[yada.interceptors/logging]
#function[yada.interceptors/return]],
:sub-resource
#function[yada.resources.file-resource/eval42586/new-directory-resource--42591/fn--42595/fn--42600]}
strange @malcolmsparks okay i will look into this a little more..
(defproject easy-map "0.0.0"
:description ""
:url ""
:license {:name ""
:url ""}
:dependencies [[aero "1.0.0"]
[org.clojure/tools.logging "0.3.1"]
[com.taoensso/timbre "4.7.0"]
[org.clojure/clojure "1.8.0"]
[im.chit/hara "2.4.0"]
[funcool/suricatta "1.1.0"]
[cheshire "5.6.3"]
[migratus "0.8.29"]
[com.layerware/hugsql "0.4.7"]
[org.postgresql/postgresql "9.4.1207"]
[hikari-cp "1.7.1"]
[funcool/cats "2.0.0"]
[prismatic/schema "1.0.5"]
[bidi "2.0.10"]
[yada "1.1.33"]
[aleph "0.4.1"]
[mount "0.1.10"]
[org.clojure/tools.namespace "0.2.11"]
[buddy/buddy-hashers "0.14.0"]
[buddy/buddy-sign "1.1.0" :exclusions [org.clojure/tools.reader]]
[hiccup "1.0.5"]]
:profiles {:dev {:source-paths ["dev" ]
:dependencies [[org.clojure/tools.nrepl "0.2.11"]
[ring/ring-mock "0.3.0"]
[clj-http "2.2.0"]
[juxt/iota "0.2.3"]
[helpshift/hydrox "0.1.15"]]}})
If you clone yada, do a lein repl, then (dev), (go) and goto localhost:8090/dir/ or localhost:8090/talks/ in a browser then you can see file directory serving
also edge has this construction in web_server.clj: `(-> (yada/as-resource (io/file "target")) (assoc :id :edge.resources/static))`
ok @iwillig - keep sending me stuff and I'll keep trying to suggest things to try
it's pretty straight-forward to serve a directory of resources, your code looks right to me
(mount/defstate server
:start (yada/listener
["" [["/" (index)]
["/v1/"
[["datasets"
[["" (datasets)]
["/" [[[:dataset-id] (dataset)]]]]]]]
["" (yada/as-resource (io/file "out"))]
[true (yada/yada nil)]]]
{:port 3000})
:stop ((:close server)))
hey @malcolmsparks i think i might figure out…
which i do not think will work and when i do (yada/resource nil)
in the repl i get the same error that i am seeing in the response
I wanted to play with clojure.spec with my project today and I ran into a few problems with libs not conforming to specs. Upgrading Aleph to [aleph "0.4.2-alpha8”]
, which I can do, solves one error. But I can’t upgrade to ring-swagger to [metosin/ring-swagger "0.22.10”]
where they fixed the bug there.
@kingoftheknoll scroll up to yesterday's discussion!
@iwillig (yada/resource nil)
would be cause an error yes.
got it! thanks for the bug report
@malcolmsparks very timely it seems lol. BTW love the Black Adder reference. Even though I’m in the states, I grew up watching it on PBS. That and Red Dwarf, which sadly is such a quotable show yet no one knows what I’m quoting!
@kingoftheknoll: better make myself look big!
@dominicm: no joke I did Cat's episode 1 monologue for an elementary school talent show. Was put on the spot and it was the only thing I could think of on short notice lol