-
Notifications
You must be signed in to change notification settings - Fork 5
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
Update API default response in browsers to force application/json #360
Conversation
Part of the problem with the PDS product is that when in a browser it is better viewed using a plugin. To this end, force the return type for text/html of a PDS product or list of products to be application/json. Lovely, but if you are accessig a product directly, it is kind of what you deserve and probably desire. Found how to set the content-type for the output. It can be overridden but required a rework of the list in WebMVCConfig. Turns out is is very order dependent. The current order seems to have everything working as desired while maybe not correctly. It also turns out that setting the content-type is also order dependent with requesting the body. Yikes so much hidden order requirements in the bowels of spring. Anyway, marked all of the converters with comments to hopefully keep their order correct.
Sonatype Lift is retiringSonatype Lift will be retiring on Sep 12, 2023, with its analysis stopping on Aug 12, 2023. We understand that this news may come as a disappointment, and Sonatype is committed to helping you transition off it seamlessly. If you’d like to retain your data, please export your issues from the web console. |
If you can build and run this branch give it a try. It should do what you want. It does with my firefox and the JSONView plugin as shown in the screenshot. |
put pretty print back in
in the right place
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.
Now I have 2 different behavior with my 2 chrome profiles:
The one which use to work to display json with the browser's plugin, does not work anymore:
The one which did not work, now works, although in a peculiar way I don't really understand:
Content-type of the response is still text/html
in both cases.
The request Accept headers are the same in both cases:
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
@jordanpadams @al-niessner I don't have the same JSON plugin under my 2 profiles... |
If you are seeing content-type of text/html then something is wrong with your build:
|
@tloubrieu-jpl have you tried in either Chrome or Firefox, without any plugins? No plugins should be necessary, and third-party plugin compatibility shouldn't be a concern imho. |
Will leave approval for @tloubrieu-jpl or @jordanpadams as I don't have context on exact requirements so it'd be a rubber-stamp. |
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.
That works
🗒️ Summary
Part of the problem with the PDS product is that when in a browser it is better viewed using a plugin. To this end, force the return type for text/html of a PDS product or list of products to be application/json. Lovely, but if you are accessig a product directly, it is kind of what you deserve and probably desire.
Found how to set the content-type for the output. It can be overridden but required a rework of the list in WebMVCConfig. Turns out is is very order dependent. The current order seems to have everything working as desired while maybe not correctly.
It also turns out that setting the content-type is also order dependent with requesting the body. Yikes so much hidden order requirements in the bowels of spring. Anyway, marked all of the converters with comments to hopefully keep their order correct.
⚙️ Test Data and/or Report
See screenshot:
♻️ Related Issues
Closes #356