This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-27
Channels
- # bangalore-clj (1)
- # beginners (11)
- # boot (23)
- # business (2)
- # cider (43)
- # cljs-dev (65)
- # cljsjs (17)
- # cljsrn (4)
- # clojure (144)
- # clojure-austin (4)
- # clojure-berlin (3)
- # clojure-finland (4)
- # clojure-nl (2)
- # clojure-russia (13)
- # clojure-spec (73)
- # clojure-uk (42)
- # clojured (2)
- # clojurescript (166)
- # core-matrix (4)
- # cursive (24)
- # datomic (39)
- # dirac (8)
- # hoplon (97)
- # jobs (2)
- # jobs-rus (11)
- # juxt (16)
- # lein-figwheel (8)
- # leiningen (1)
- # luminus (5)
- # lumo (46)
- # off-topic (1)
- # om (39)
- # onyx (43)
- # overtone (1)
- # pedestal (3)
- # perun (6)
- # play-clj (3)
- # protorepl (14)
- # re-frame (21)
- # reagent (25)
- # remote-jobs (1)
- # ring (1)
- # robots (4)
- # rum (13)
- # specter (5)
- # untangled (72)
- # yada (62)
So I’d like to prevent yada from sending stacktraces along with 404 responses, or any response for that matter. Is there a preferred way to do this? Right now it sounds like I would have to return a custom 404 using the :responses
key of the resource definition
but then I’d have to specifiy it for every resource and every possible response code ; which I can do with a function, but was just wondering what the best practice would be here
@achesnais for now I think the best way is your own app.yada/resource function
There's been some discussion on "profiles" in yada and having stacktraces only for dev vs prod
@achesnais you could replace the event interceptor chain with your own one. Yes, these is a feature that has been requested before and profiles might be introduced soon
It's not obligatory to declare body parameters at all.
If yada can help you by declaring them, then great, but don't let it get in your way
so I was trying to figure out how to make a redirect in resource's :response function
Edit: My mistake. Used :host
instead of :domain
in the cookie map in my tests.
Hello. I'm trying to use the response-for
function to test my yada resources/endpoints. It does not seem however that the function's return value contains the cookies set in the response by the resource handler. When I log the response object in the resource handler the yada.context.Response
map contains them. Any way to get the cookies via response-for
or do I have to figure out another way to test resources that returns cookies?
@sickill That looks good, if you add ring as a dependency, you can do:
(merge (:response ctx) (ring.util.response/redirect "
@dominicm I was thinking about that, but wasn't sure how compatible that is (ie. whether ring fns do too much/override stuff with incompatible type(s) etc)
@dominicm re our discussion from last Friday about forcing specific representation via url suffix (`.png`, .gif
etc). What about wrapping whole handler with a middleware that would update accept
header and :uri
in the request map?
@sickill Interesting idea. It risks being a little "magic" but could definitely work.
afaik the request map that is passed from aleph to yada/handler (or to bidi routing tree coerced to yada/handler) is just regular ring request map, right? so technically that would work (unless I modify the response, which I wouldn't here)
yes, it's in docs
for ex, there's lots of talk about ETag in the manual but it doesn't mention :version
property which is used for this (I eventually found it in a blog post)
the manual also doesn't say that custom keywords in :properties
map should be namespaced (it mentions namespacing in the section about resource model, but the section about properties says "anything you return will be placed in the :properties entry of the request-context", maybe it's worth repeating there that you must namespace keywords)
I’m struggling a bit to add basic auth (or any custom auth) to a resource handler (serving files off the filesystem) - and I have a feeling like if I can just compose the right functions that this is a trivial thing to do.
Yes. I have 4 blogs in the pipeline all around auth. 2 are in review
But start with the file and resources in the yada codebase: src/yada/resources/file_resource.clj
Suggest you copy and paste, get working and then transplant your auth code into the original file resource @peterwestmacott
I’ll give that a go, thanks
I’ve got something that works, and its mostly a mash-up of various functions in various yada/resources namespaces
I can’t help but feel that there are a lot of functions that return ‘resources’ that almost return ‘resource models’, and that if they returned ‘resource models’ they would be easier to re-use - one could simply alter the maps they return. But of course there may well be good reasons for the current design that I don’t understand. I am still getting my head around yada.
hello sorry for the newbie question I don't understand how to handle https with yada works fine locally with http
(def handler
(yada/handler "Hello World!"))
(defn -main []
(netty/wait-for-close
(http/start-server handler {:port port})))
There is the part in the manual about HSTS, but I don't understand how to use it I'm behind an Nginx reverse proxy
Well, looks like it was more an nginx config problem! 😅
now I do proxy_pass
before I used https, and I guess that it's why aleph couldn't get it
I should learn more about ssl and https, just to make sure it's safe to do this, and to understand why
True! I've reported a bug in Google Cloud Loadbalancer because of yada's compliance with the spec.
@peterwestmacott but you can alter yada resources, just like maps!
I want to create my own wrapper for yada/resource and was wondering whether I should alter the map before passing to yada/resource or after. Isn't yada/resource generating interceptor chains or other model props based on input map? Or it just fills the blanks?
@stijn cloudbleed has motivated me to look into supporting https more natively in yada/aleph. Now we cannot trust nginx...
Publishes tomorrow noon, please keep private until then
But any feedback welcome of course