-
Notifications
You must be signed in to change notification settings - Fork 145
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
Add JSON responses #250
Add JSON responses #250
Conversation
Return HTML or JSON , with the format chosen to match the request accept header. Additionally, rewrite requests with URLs that end in ".json" to their equivalent document without an extensnion but with the appropriate accept header to receive a JSON response.
I've left the last two bullet points un-checked. I'm seeking feedback on:
|
Following |
@tilgovi Thanks so much for taking on this feature, which I think will be useful for lots of programmatic use cases. What you have so far seems right to me, the only thing I've spotted is that it looks like the tests are not passing because the deep equal assertion is finding additional fields in the test data that are not part of the match. I wonder if using objectContaining instead of deepEqual would solve that, and then we could move forward with finalizing and merge? I also see you are adding JSON support for the search endpoint, which could be a help for another use case I heard about recently. (cc @crystalnyt) |
Thanks, @isaacwhite. I just wanted some confirmation that the fields being returned look correct and like they're named in a sane and consistent way. I'll get the tests passing and come back today/tomorrow. |
Still following. |
Co-authored-by: Isaac White <isaacwhite@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏🏻 This is great, thanks so much for building support for this into Library core @tilgovi and @smores! We're really excited by the integrations that it will make possible with other services, and plan to take advantage of it for some future issues (like #242), which could integrate well with these new endpoints.
Let me know if you have any other questions. I plan to merge this later today.
Description of Change
Return HTML or JSON , with the format chosen to match the request accept
header.
Additionally, rewrite requests with URLs that end in ".json" to their
equivalent document without an extensnion but with the appropriate
accept header to receive a JSON response.
Motivation and Context
I'd like to embed content from a Library instance in another product. Library is under active use and a different group of people manages its content than the team responsible for the product into which the Library content will be embedded. For maintainability, it's preferable to fetch that content from Library on the fly, and not be subject to the templating in Library.
Checklist
npm run lint
and updated code style accordinglynpm run test
passes