Question: I’ve only skimmed the docs so apologies if this is mentioned there — is there a way to add a pervasive middleware across all handlers/routes? BTW, thanks for all this! Or perhaps a bit more interestingly, across *some* handlers?

Asked By
Asked At
2018-03-19 15:32:03

Found 15 possible answers.

User Answered At Possible Answer
dominicm 2018-03-19 15:52:46 @orestis yada doesn't have middleware :stuck_out_tongue: . It does have interceptors, you can add it to some by using clojure.walk/postwalk on a routing data structure.
orestis 2018-03-19 15:57:42 Cool, sounds like having the resources being data structures enables a lot of cool stuff :slightly_smiling_face:
borkdude 2018-03-19 17:21:08 @orestis yes, that’s very convenient
tanzoniteblack 2018-03-19 17:23:55 speaking of yada, anyone have thoughts on ; it's pretty simplistic and just allows you to directly pass the return schema directly through to ; currently the only thing that's preventing it is that the schema doesn't allow the key :schema in responses (and yes, of course we're speaking of yada on #yada )
nha 2018-03-19 17:31:43 looks good to me (didn’t try running it) I guess the next step would be to actually use the schema to check/validate the reply and not use it just for documentation.
severed-infinity 2018-03-20 22:19:50 Hi guys, looking for a bit of help with this piece of code
(defn resource-routes []
Also on top of that, what is the correct way to shutdown the server. As per the documentation I call `((:close (resource-routes)))` but it returns `CompilerException Address already in use` which means I cannot refresh changes without forcing closed the REPL and occasionally having to open up *Activity Monitor* and force close form there. What I am asking what is the best/right way to close/restart the server.
I’m building a very simple website (a single page to be precise) but I am having trouble getting yada to serve up the files in _resources/public/…_ directory, I’ve tired a few different approaches to the above but thats were I currently left it off; Working with the webpage directly for the mean time. {:port 5000})) ["/" (yada/handler (resource "/resources/"))]]] [["/" (yada/handler (file "app.html"))] ["" (yada/listener
dominicm 2018-03-20 22:21:57 I think that should be (resource "") or maybe it should be the yada classpath resource from the namespace of the same name
severed-infinity 2018-03-20 22:25:05 I tried the (new-classpath-resource) and it didn’t work for me either, I had looked at an old response for more or less than same issue I am having and it suggested the classpath resource though that didn’t work for me.
dominicm 2018-03-20 22:27:00 We use it, it certainly works. But it never works how I expect it to.
severed-infinity 2018-03-20 22:27:05 using (new-classpath-resource) produces, in the browser, Failed to load resource: the server responded with a status of 404 (Not Found)
dominicm 2018-03-20 22:28:21 Oh, I remember how it works, try "" instead of "/" for the bidi route for your classpath resource
severed-infinity 2018-03-20 22:31:13 @severed-infinity uploaded a file: Screen Shot 2018-03-20 at 22.29.40.png and commented: Given the above folder structure and the following as you suggested
(defn resource-routes []
I’m still getting a 404 :disappointed: {:port 5000})) ["" (yada/handler (new-classpath-resource "/resources/"))/span [["/" (yada/handler (file "app.html"))] ["" (yada/listener
dominicm 2018-03-20 22:34:16 Oh, also don't do "/resources/", turn that to ""
severed-infinity 2018-03-20 22:37:31 Still getting 404 , it’s odd why I can’t get it to work
dominicm 2018-03-20 22:39:41 I may have been wrong, it may be "/", as the path. I'm afk, else I'd just spin this up and check by stepping through what it looks up

Related Questions