manyminds / api2go

JSONAPI.org Implementation for Go
MIT License
696 stars 93 forks source link

handleRead hardcodes http.StatusOk as status code #243

Open tochiai opened 8 years ago

tochiai commented 8 years ago

It is not possible to set a response status code via the response returned by FindOne; the status code is set to http.StatusOk. Would it be possible to add logic in handleRead to try to use response.StatusCode()?

sharpner commented 8 years ago

The specification of jsonapi only specifies 200 for OK and 404 for not found. http://jsonapi.org/format/#fetching-resources

Could you describe your problem a little bit?

tochiai commented 8 years ago

I was trying to follow this pattern for asynchronous processing http://jsonapi.org/recommendations/#asynchronous-processing

Glossing over some name changes, I'm basically trying to implement the part where a 303 is returned for GET /photos/queue-jobs/5234.

My reading of the spec allows for other status codes when fetching a resource, what do you think? http://jsonapi.org/format/#fetching-resources-responses-other

wwwdata commented 8 years ago

you are right, I looked at the code and this is a bug.

Theoretically you should be able to set a status code in the Responder, but in our FindOne method of the api, we always set a 200 which is not right. We have to change this.

sharpner commented 8 years ago

Regardless of wether it is a bug or a feature, the next problem will be to implement the "see other" location header. But I'm working on it. If you can live without the self link which is handled in #99 it should be done soon. :-)

sharpner commented 8 years ago

@tochiai I implemented most of the basics in #244 if you want you can test it. But its not yet possible to perfectly implement it.