Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider additional parameters in main response object. #43

Closed
Deiru2k opened this issue Jun 17, 2014 · 3 comments
Closed

Consider additional parameters in main response object. #43

Deiru2k opened this issue Jun 17, 2014 · 3 comments

Comments

@Deiru2k
Copy link
Contributor

Deiru2k commented Jun 17, 2014

Right now, if I a successful request is served, {'status': 'success', 'data': 'YOURDATA'} will be in an output. It would be nice if one could provide additional information (i.e. total number of objects and page offset for pagination) inside an additional parameter, like {'status': 'success', 'data': 'YOURDATA', "_meta": {"offset" 10, "totalCount": 24}}.
I know that this is kinda against JSSend specification, but I think that this will be a very nice feature.

@hfaran
Copy link
Owner

hfaran commented Jun 18, 2014

Hi!

While this is a very good idea; I'm not sure this is something that is easy to integrate into Tornado-JSON, or is a good fit for it.

When I first wrote Tornado-JSON, it was with the intention that it would be used to write relatively simple APIs; hence why I chose JSend as the specification for responses. It seems like you want a much more fully-features specification, such as JSON API. This is difficult to integrate with Tornado-JSON as it stands right now because it is geared towards simplicity.

That being said, this is certainly something that is POSSIBLE to integrate so I would love it if you could provide maybe an example of what the interface or implementation could look like, i.e., how you would go about adding pagination to responses.

@hfaran
Copy link
Owner

hfaran commented Jun 18, 2014

If you wanted to implement this yourself, you could simply create your own Mixin class similar to JSendMixin but one which defined a custom standard to your liking and then have an APIHandler class multi-inherit from that. You would also have to implement your own schema.validate method of course.

@hfaran
Copy link
Owner

hfaran commented Mar 3, 2016

Going to close this because I don't think this would be in appropriate scope. A very easy way to accomplish this would be to simply add the _meta keyword your actual data response, i.e.,:

{"status": "success", "data": {"_meta": ..., "foo": "bar", ...}}

This would then still fit within the confines of JSend.

@hfaran hfaran closed this as completed Mar 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants