This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-25
Channels
- # beginners (32)
- # boot (1)
- # cljs-dev (25)
- # cljsrn (1)
- # clojure (35)
- # clojure-dev (6)
- # clojure-nl (4)
- # clojure-russia (12)
- # clojure-spec (13)
- # clojure-switzerland (2)
- # clojurescript (63)
- # cursive (9)
- # datomic (18)
- # dirac (32)
- # graphql (6)
- # luminus (8)
- # off-topic (18)
- # pedestal (5)
- # protorepl (1)
- # re-frame (30)
- # remote-jobs (5)
- # untangled (61)
- # yada (7)
Question: did anyone give some thoughts to declaring the paths in the resources? Good idea/bad idea?
(yada/resource {:custom/path "/api/path"
:methods {:get {:response (fn [ctx]
(assoc ctx :body "ok"))}}})
No real problem with it. It's all data after all @nha. But you are fixing a one-to-one cardinality between paths and resources there. Generally I encourage separation of identity and resource.
Wouldn't something like that allow a resource to be accessible through multiple paths?
(yada/resource {:custom/path (->MultiPath
"/api/path"
"/api/another-path")
:methods {:get {:response (fn [ctx]
(assoc ctx :body "ok"))}}})
I guess what constitutes the identity vs what is the resource is not clear to me. I will have to read about it 🙂A URI is different from the web resource. URIs are specified in a different (earlier) RFC to HTTP. For example, @nha is an idenifier and identifies you, but is not you.
(yada/response-for (yada/resource {:methods {:get {:produces [{:media-type #{"application/json;q=0.9"
"application/transit+json;q=0.8"
"application/edn;q=0.7"
"text/html;q=0.6"}
:charset "UTF-8"}]
:response (fn [ctx]
{:content "some-content"})}}})
:get
"ignore-me"
{:headers {"content-type" "application/edn"}})
This returns a map with :headers "content-type" "application/json", and the :body is JSON indeed.
How do I get edn or transit in the :body ?