main.io.github.tabilzad.ktor.HttpCodeResolver.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ktor-docs-plugin Show documentation
Show all versions of ktor-docs-plugin Show documentation
Open API (Swagger) specification Generator for Ktor
package io.github.tabilzad.ktor
// to use for automatic response interpretation
object HttpCodeResolver {
fun resolve(code: String?): String = codes[code] ?: "200"
private val codes = mapOf(
"Continue" to "100",
"SwitchingProtocols" to "101",
"Processing" to "102",
"OK" to "200",
"Created" to "201",
"Accepted" to "202",
"NonAuthoritativeInformation" to "203",
"NoContent" to "204",
"ResetContent" to "205",
"PartialContent" to "206",
"MultiStatus" to "207",
"MultipleChoices" to "300",
"MovedPermanently" to "301",
"Found" to "302",
"SeeOther" to "303",
"NotModified" to "304",
"UseProxy" to "305",
"SwitchProxy" to "306",
"TemporaryRedirect" to "307",
"PermanentRedirect" to "308",
"BadRequest" to "400",
"Unauthorized" to "401",
"PaymentRequired" to "402",
"Forbidden" to "403",
"NotFound" to "404",
"MethodNotAllowed" to "405",
"NotAcceptable" to "406",
"ProxyAuthenticationRequired" to "407",
"RequestTimeout" to "408",
"Conflict" to "409",
"Gone" to "410",
"LengthRequired" to "411",
"PreconditionFailed" to "412",
"PayloadTooLarge" to "413",
"RequestURITooLong" to "414",
"UnsupportedMediaType" to "415",
"RequestedRangeNotSatisfiable" to "416",
"ExpectationFailed" to "417",
"UnprocessableEntity" to "422",
"Locked" to "423",
"FailedDependency" to "424",
"UpgradeRequired" to "426",
"TooManyRequests" to "429",
"RequestHeaderFieldTooLarge" to "431",
"InternalServerError" to "500",
"NotImplemented" to "501",
"BadGateway" to "502",
"ServiceUnavailable" to "503",
"GatewayTimeout" to "504",
"VersionNotSupported" to "505",
"VariantAlsoNegotiates" to "506",
"InsufficientStorage" to "507"
)
}