To sum up the discussion above: - In most cases, a...
# server
c
To sum up the discussion above: • In most cases, an endpoint only ever responds with a single status code [ignoring error situations] • If an endpoint can return multiple status codes for a success, it's most often derivable from the value itself ◦ Example: Ktor uses
204 No Content
when the result type is
Unit
◦ Example: Returning a sealed type with a
"type": "Created"
discriminator which matches the status code. It is possible to deserialize the data without knowing the status code, it's purely redundant information ◦ Example: returning
204 No Content
when a resulting list is empty • Rarely, the status code is actually used for discriminating between completely different data, such that it's not possible to deserialize without knowing it ◦ Example: somewhere in openresponses.org apparently, but I've not found where ◦ There is no evidence of this being used in a server written in Kotlin