Fork me on GitHub
#yada
<
2017-03-10
>
grav08:03:54

How do you test yada routes without having to spin up the listener?

grav08:03:31

Cool, thanks!

malcolmsparks08:03:21

request-for also a thing

malcolmsparks08:03:39

yet another thing I must give Pedestal credit for coming up with. Copying is a form of flattery ;)

grav09:03:02

Cool ๐Ÿ™‚

grav09:03:34

Btw, I have a suggestion re: documentation, should I open up an issue or take it here?

sickill10:03:57

how can I coerce bidi tree to yada handler explicitly? I try yada.handler/as-handler (this is what I found in aleph/listener), but the response for any request is some nested html table with :body, :headers and :status 501

dominicm10:03:07

@sickill yada is missing a function as-handler protocol

dominicm10:03:45

If you extend the HandlerCoercion protocol to handle functions, it works.

dominicm10:03:06

Had this issue the other day also ๐Ÿ˜› Haven't been able to contribute it back though

sickill10:03:53

@dominicm what I'm trying to do is wrap top level yada handler (bidi tree actually) in a middleware, so I thought I'll first make it a yada handler (which implements IFn afaik and can be called by middleware)

dominicm10:03:31

@sickill

(extend-protocol HandlerCoercion
  clojure.lang.Fn
  (as-handler [this] this))

sickill10:03:55

ah, it's that simple ๐Ÿ™‚ thx

sickill10:03:26

would it make sense to add this to yada, or maybe there are some edge cases which prevent it from being added there?

dominicm10:03:32

I think it makes sense

dominicm10:03:54

It's just that I ran into this only a couple days ago & haven't had time to add it.

dominicm10:03:46

Feel free to open the PR if you have the time ๐Ÿ˜‰

sickill10:03:06

yes! was looking for the opportunity to make my first contribution to yada ๐Ÿ™‚

sickill10:03:23

other thing, does yada support specifying media-type "qualities" server-side with qs=0.9 param?

sickill10:03:15

for ex when client sends Accept: */* and I prefer to send text/html over application/json

dominicm10:03:57

I think so, yes.

sickill10:03:01

Apache (http://httpd.apache.org/docs/current/content-negotiation.html) and other web servers support that for content negotiation

dominicm10:03:01

But I woldn't sear to it.

dominicm11:03:03

I like that I can delete code once that's in.

dominicm11:03:08

Deleting code > writing code

sickill11:03:16

when I was a kid I thought deleting code < writing code, but now I concur with the above

dominicm11:03:53

I have fun deleting code

sickill11:03:20

anyway, checked setting qualities for declared media-types in :produces, works great (with q=, not qs=)

sickill11:03:11

I have old clients running out there which are sending Accept: */* but always expecting html response, this will greatly help when adding more representations to this resource โค๏ธ

dominicm11:03:39

Ah, q, that sounds more familiar!

achesnais11:03:47

Has anyone managed to set non-clojure.core global vars via the :global-vars key in the project.clj? Iโ€™m trying to set a value for yada.body/*output-errors* but getting a ClassNotFound exception Or is there a better way to set the value of that var?

sickill12:03:56

@achesnais thanks for mentioning yada.body/*output-errors*, I was looking for a way to hide errors/stack traces and ended up with overrided whole range of 4xx/5xx status responses

achesnais12:03:43

haha yes thatโ€™s exactly what I was trying to avoid

sickill12:03:53

would be nice to have this mentioned in the manual though

achesnais12:03:03

itโ€™s in the source! ๐Ÿ˜„

sickill12:03:11

well yeah... ๐Ÿ™‚

achesnais12:03:55

Iโ€™d love for it not to be a global var, but rather an option passed in to the yada/listener constructor. That way you the printing of stacktraces is decided by your config

chillenious14:03:11

yada looks really cool

dominicm14:03:06

As an fyi, I think only yada.yada is the public api, everything else is "implementation detail" subject to change

chillenious14:03:23

Declaratively coding your resources has always been a good idea with terrible implementations in other languages (especially when that involves another xml dsl)โ€ฆ but this looks great

dominicm14:03:54

It's an interesting concept, I wonder if people will grasp the extension points. For example, I wanted to have a simpler Access Control system that was app-wide, so I used a custom attribute :myapp/permissions which described in my domain the possible restrictions: {:post :public :get :logged-in} Very simple in yada

grav22:03:44

Seems ?foo=bar%25 ends up as {:foo nil} instead of {:foo โ€œ%โ€) when parsed. Can anyone confirm this?

grav23:03:42

Oh dear, only yada.test/request-for makes this error, since it does an extra round of decoding. But request-for isnโ€™t actually used when running a request through the server for real ๐Ÿ™‚