kotlin-server.libraries.ktor.api.mustache Maven / Gradle / Ivy
{{>licenseInfo}}
package {{apiPackage}}
import com.google.gson.Gson
import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.auth.*
import io.ktor.server.response.*
{{#featureResources}}
import {{packageName}}.Paths
import io.ktor.server.resources.options
import io.ktor.server.resources.get
import io.ktor.server.resources.post
import io.ktor.server.resources.put
import io.ktor.server.resources.delete
import io.ktor.server.resources.head
import io.ktor.server.resources.patch
{{/featureResources}}
import io.ktor.server.routing.*
import {{packageName}}.infrastructure.ApiPrincipal
{{#imports}}import {{import}}
{{/imports}}
{{#operations}}
fun Route.{{classname}}() {
val gson = Gson()
val empty = mutableMapOf()
{{#operation}}
{{#hasAuthMethods}}
{{#authMethods}}
authenticate("{{{name}}}") {
{{/authMethods}}
{{/hasAuthMethods}}
{{^featureResources}}
route("{{path}}") {
{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}} {
{{#lambda.indented_12}}{{>libraries/ktor/_api_body}}{{/lambda.indented_12}}
}
}
{{/featureResources}}
{{#featureResources}}
{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}} {
{{#lambda.indented_8}}{{>libraries/ktor/_api_body}}{{/lambda.indented_8}}
}
{{/featureResources}}
{{#hasAuthMethods}}
}
{{/hasAuthMethods}}
{{/operation}}
}
{{/operations}}