https://kotlinlang.org logo
#ktor
Title
# ktor
m

Michael Waitt

03/03/2023, 10:36 PM
Hello! Quick question about the server
ContentNegotiation
plugin. We have a ktor server where all well-formed request bodies will be Json. Some requests will come from other systems, some will come from users. So we cannot guarantee that
Content-Type
will be passed every time. Is there a recommended way to handle a missing Content-Type so we can use ContentNegotiation for our server? Is there maybe a clean way to specify a default Content-Type at the server or route level? We're really trying to cleanup manual de/serialization of request bodies.
1
e

ephemient

03/03/2023, 10:47 PM
tried matching
*/*
?
Copy code
register(ContentType.Any, KotlinxSerializationConverter(Json))
🙌 1
m

Michael Waitt

03/03/2023, 11:04 PM
That works great. Thank you!!
5 Views