Implement Content Negotiation feature
See original GitHub issueCurrently, if I want to send back a response in JSon, I have to do
install(GsonSupport)
This feels like it’s coupling a specific implementation of Json encoding with the feature of actually representing a response with a specific content type.
Considering generalising this support with something more generic such as
install(AutoContentType)
and register different content types with specific serialisers/deserialisers. For instance
register("application/json", GsonSerialiser)
register("application/xml", XmlSerialiser)
and then allow the respond call to specify the content type
call.respond(listOf(myStuff), "application/json")
which will be picked up by the correct serialiser.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:13 (8 by maintainers)
Top Results From Across the Web
Content negotiation - HTTP - MDN Web Docs
In HTTP, content negotiation is the mechanism that is used for serving different representations of a resource to the same URI to help...
Read more >Content Negotiation using Spring MVC
In this post I want to discuss how to configure and use content negotiation with Spring, mostly in terms of RESTful Controllers using...
Read more >Content Negotiation Implementing Support for XML - Javatpoint
Content negotiation is the process of selecting the best representation for a given response when there are multiple representations available. It is a...
Read more >Spring MVC Content Negotiation - Baeldung
A guide to configuring content negotiation in a Spring MVC application and on enabling and disabling the various available strategies.
Read more >Implement Content Negotiation using Spring Boot - JavaInUse
In this post we implement a simple Spring Boot example to implement Content Negotiation for returning XML or JSON depending upon the URL...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@McPringle agree, that’s the plan. It should be something like this:
(error handling omitted for clarity)
Same for
call.receive<User>()
for POST data.Please see http://ktor.io/features/content-negotiation.html for details.