question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to have multiple ContentNegotiation, separate per module?

See original GitHub issue

Ktor Version

1.1.2

When trying to install ContentNegotiation inside additional (not main) module:

install(ContentNegotiation) {
        register(ContentType.Application.Xml, MyContentConverter()) {

        }
    }

I have this error:

Caused by: io.ktor.application.DuplicateApplicationFeatureException: Conflicting application feature is already installed with the same key as `ContentNegotiation`

however I would like that part of the routes could by default use different content negotiation. some API require to have XML.

The per route can be defined with help of contentType:

routing {
        contentType(ContentType.Application.Xml){
            get("/myxml/api"){
                
            }
            
        }

Is there way to have that configured per module, how the ContentNegotiation happens?

That would help to have modules as separate dependencies to be reused on different Ktor applications.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
e5lcommented, May 2, 2022

Hi, since 2.0.0 it’s possible to install different ContentNegotiation plugins for separate routes

0reactions
oleg-larshincommented, Aug 10, 2020

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Content negotiation and serialization
The ContentNegotiation plugin serves two primary purposes: Negotiating media types between the client and server. For this, it uses the ...
Read more >
NancyFx per module or per route serialization
I have a single return type per module, but in different URL routes I need to serialize it differently, just specific properties. If...
Read more >
Content Negotiation - Apache HTTP Server Version 2.4
Content negotiation is provided by the mod_negotiation module, which is compiled in by ... A resource may be available in several different representations....
Read more >
Enable header-based proactive content negotiation with ...
By HEAD not currently honoring an unambiguous Accept header, we have the following bug: - Perform jQuery.ajax('/node/1', {'headers': {'accept': ...
Read more >
Spring Boot Multi Module Project
Spring Boot Multi Module Project with Introduction, Features, Project, ... so we need not to specify the same dependency in each module separately....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found