Fork me on GitHub
#yada
<
2017-01-16
>
malcolmsparks11:01:14

Hi @geek-draven - for a project.clj driven yada, take a look in dev/ and following the instructions in the README to get the dev project up - that's the project I work in when I'm developing yada and it currently has some simple examples and the manual is available. This is all on the master branch.

malcolmsparks11:01:01

A good rule-of-thumb is to get acquainted with yada internals by looking at the code. The core is not that complex, it's really just a chain of functions passing along a single argument (called the context)

malcolmsparks11:01:25

There's a lot of code in yada but once you understand where the pieces fit, you can ignore a great deal of it

malcolmsparks11:01:15

@geek-draven - a technical point but the routing is edge is done with bidi. In yada, you secure each resource individually - you can automate this using a clojure.walk/postwalk or find many alternative ways of adding authorization to the resource data

malcolmsparks11:01:39

The 2 interceptors are authentication and authorization - once you understand how they work it's quite powerful

malcolmsparks11:01:17

@naartjie - no, but you could avoid declaring {:parameters {:body ...}} and handle the body yourself

malcolmsparks11:01:45

@naartjie But I see that it's not ideal - what's your use-case?

naartjie11:01:35

@malcolmsparks we have a post which takes no body or alternatively a {:comment String}. I could try have a go at a PR

malcolmsparks11:01:23

yes - do you think you can detect a (s/optional-key :body) ?

naartjie12:01:09

Do you mean detect in my code or in yada/the PR?

stijn14:01:12

@malcolmsparks the github repo says to use [yada "1.2.1"] but it hasn't been published

malcolmsparks14:01:02

My bad, sorry, use 1.2.0

stijn14:01:12

ok, and it is backwards compatible with 1.1.47?

malcolmsparks14:01:10

Broadly compatible, but test ofc

naartjie14:01:41

@stijn I found that the optional body used to work for us, in 1.1.18 at least, after upgrading to 1.2.0 I haven't found a way to make it work. Also, if you were throwing ex-info with :body in ex-data, that will be respected now.

naartjie15:01:33

@malcolmsparks I could sure try ;) For the body schema something like :body (s/maybe schema) for the :parameters definition of the resource should be the expected from the user?

stijn15:01:47

how should you manipulate the interceptor chain in 1.2.0? as =>> No such var: yada.resource/insert-interceptor

stijn15:01:23

I see a multimethod in yada.yada, but not sure how to extend it

malcolmsparks15:01:29

those convenience functions have gone to yada.handler

malcolmsparks15:01:12

the idea is that yada.yada is the API - if you depend on anything outside of yada.yada then it might break

malcolmsparks15:01:26

this allows me to refactor while keeping the API compatible

malcolmsparks15:01:57

the multimethod in yada.yada is new and still experimental, don't depend on it yet

malcolmsparks15:01:33

that's why I said 'broadly compatible' 🙂

malcolmsparks15:01:36

in future, I'm going to take care to keep yada.yada stable - of course there are some functions that I've indicated in documentation and elsewhere outside of yada.yada which I shall clean up - consider everything outside of yada.yada to be risky to depend on

stijn15:01:16

sure, not much that we depend on outside of yada.yada

naartjie15:01:40

@malcolmsparks so in orther words if we're doing (defmethod yada.security/verify :jwt ...) and (defmethod yada.authorization/validate ...) in our code we should definitely watch out 🙂

malcolmsparks15:01:26

Those will be moved into yada.yada at some point

naartjie15:01:38

ah, great, good to know (will sleep better now) 😉

stijn15:01:16

this is weird, if i switch from 1.1.45 to something higher (also 1.1.46) every GET with a 200/OK has an empty body

malcolmsparks15:01:38

Really? Which version

malcolmsparks15:01:07

Is there some cacheing thing?

stijn15:01:27

not on localhost no

stijn15:01:32

from 1.1.45 to 1.1.46

stijn15:01:03

1.1.47 complains there is no yada.yada namespace

stijn15:01:45

also in git, tag 1.1.47 src/yada/yada.clj is gone

stijn15:01:51

1.2.0 also empty response

stijn15:01:31

i'll fire the debugger, hold on 🙂

malcolmsparks15:01:37

that can't be right

malcolmsparks15:01:54

I'm using yada 1.2.0 and I would certainly notice that!

stijn15:01:27

i think i have something messed up with the interceptors as it never enters the fn in :response

malcolmsparks15:01:45

ah, that's possible

stijn16:01:52

i'll need to debug this another time, will let you know

geek-draven19:01:57

@malcolmsparks Thanks Malcolm, I've made some progress today and got the server working, now just need to figure out where I went wrong with my yada resources as the page is displaying the raw html code

malcolmsparks20:01:29

@geek-draven Make sure you're declaring :produces mediatype to be text/html :)