Fork me on GitHub
#ring-swagger
<
2016-03-24
>
mikecarter11:03:42

@ikitommi: i got around to writing my custom meta-data handler, if you have time it'd be great if you could let me know if i'm going about it the right way - https://gist.github.com/mikos/071f542d1d9085cb6536 thanks 😃

juhoteperi12:03:31

@mikecarter: I would recommend moving the binding symbol to metadata, something like: :load-entry [entry (find-by-id ...)]

mikecarter12:03:37

@juhoteperi: thanks! then pass the entry to :exists? - is this the best way to return a 404 if an entry doesn't exist?

juhoteperi12:03:37

I wouldn't say there is one way that is better than others

juhoteperi12:03:49

With c-api I have just written the check inside handler body

juhoteperi12:03:05

But :exists? meta handler looks like what we have been doing with Kekkonen

mikecarter12:03:28

cool, thanks man simple_smile

mikecarter12:03:33

it's just a feature i liked when i used Liberator

juhoteperi12:03:06

Maybe it would make sense to do both exist check and load in one handler (like currently)

mikecarter12:03:17

yeah - that's how Liberator does it I believe

mikecarter12:03:24

it loads it if it exists, and 404s if not

juhoteperi12:03:33

But I would recommend changing the magic _entry symbol to one what is defined in metadata

juhoteperi12:03:01

And I'm not sure but possibly using anonymous function in macro like that might be non-optimal

juhoteperi12:03:57

I think the code in gist will recreate the anonymous function for each request

mikecarter12:03:45

ah - i'll look into that, thanks

mikecarter12:03:04

not sure how else to do it as find-by-id obviously relies on the ID being passed in the request

mikecarter12:03:18

perhaps it would be simpler to have the check in the body, as you said previously