Clojurians
#yada
<
2016-03-18
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

malcolmsparks07:03:45

thanks - I need to update http://yada.juxt.pro - having slight issues with vhosts for that which I'm fixing. In the meantime please use https://github.com/juxt/yada/blob/master/manuscript/030_hello.md

imre14:03:16

hello again

imre14:03:15

I'm implementing an api endpoint that accepts and serves binary files (Content-Type: application/octet-stream plus the Content-Disposition header)

imre14:03:14

under normal circumstances your PUT operations would result in 204 No Content and your GETs in 200 with the file as the content

imre14:03:47

so it makes sense to set consumes and produces to application/octet-stream

imre14:03:44

but if there is an error, say an unsupported file extension is being PUT, I might want to return error details

imre14:03:17

octet-stream is not the best for that

imre14:03:46

so in error cases I would want to return something more meaningful like json or edn

imre14:03:43

This brings up a few questions:

imre14:03:29

- As content negotiation will happen before some of these errors are detected, can I override the already negotiated content type?

imre14:03:41

- Do I need to advertise the content types I only use for error reporting?

imre14:03:03

In fairness, this is a strange endpoint alright. If we look at only the happy paths, PUTs don't need to have produced content-type as they should not return content

imre14:03:30

I could specify edn and json as produced for the sake of PUT but then what would prevent someone from specifying edn in Accept for a GET?

imre15:03:46

Correction: now that I dived into the yada code I see that select-representation happens after the request body is processed so I might be able to do something there

imre15:03:46

my previous statement might not be true

imre16:03:38

okay, I just found out that you can specify :consumes and :produces per method if you wish to

imre16:03:52

that does help simple_smile

malcolmsparks18:03:23

@imre upon error, yada will re-negotiate the content type. Your status responses can declare their own :produces. The only thing that remains constant is the user agent's Accept header. This design is born of the painful experience we had trying to do this in Liberator, which was somewhay constrained by the webmachine graph.

imre18:03:19

nice one

imre18:03:19

one possible problem I see is when your supported happy path representations are different to your error path representations

imre18:03:40

GET, normally serving binary but serving errors in json

imre18:03:24

I like that

imre18:03:43

yada is awesome simple_smile

malcolmsparks18:03:58

data is awesome :)

imre18:03:43

that too simple_smile

malcolmsparks18:03:48

There's been some memory exhaustion issues with yada (actually netty) at scale lately but we may have solved them. Anyone in @channel experiencing any issues please get in touch

mccraigmccraig18:03:40

@malcolmsparks: were the mem issues related to async file upload ?

malcolmsparks21:03:52

@mccraigmccraig yes