File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed
src/main/kotlin/no/java/conf/plugins Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -7,18 +7,19 @@ import io.ktor.server.response.respondRedirect
77import io.ktor.server.routing.RoutingContext
88import no.java.conf.model.ApiError
99
10- context(RoutingContext )
11- suspend inline fun <reified A : Any > Either <ApiError , A >.respond (status : HttpStatusCode = HttpStatusCode .OK ) =
10+ suspend inline fun <reified A : Any > Either <ApiError , A >.respond (
11+ context : RoutingContext ,
12+ status : HttpStatusCode = HttpStatusCode .OK
13+ ) =
1214 when (this ) {
13- is Either .Left -> respond(value)
14- is Either .Right -> call.respond(status, value)
15+ is Either .Left -> context. respond(value)
16+ is Either .Right -> context. call.respond(status, value)
1517 }
1618
1719suspend fun RoutingContext.respond (error : ApiError ) = call.respond(error.statusCode, error.messageMap())
1820
19- context(RoutingContext )
20- suspend inline fun <reified A : Any > Either <ApiError , A >.respondRedirect (url : String ) =
21+ suspend inline fun <reified A : Any > Either <ApiError , A >.respondRedirect (context : RoutingContext , url : String ) =
2122 when (this ) {
22- is Either .Left -> respond(value)
23- is Either .Right -> call.respondRedirect(url)
23+ is Either .Left -> context. respond(value)
24+ is Either .Right -> context. call.respondRedirect(url)
2425 }
Original file line number Diff line number Diff line change @@ -86,15 +86,15 @@ fun Application.configureSearchRouting(service: SearchService) {
8686 get(" /videos" ) {
8787 either {
8888 service.allVideos()
89- }.respond()
89+ }.respond(this )
9090 }
9191
9292 post {
9393 either {
9494 service.textSearch(
9595 runCatching<TextSearchRequest ?> { call.receiveNullable<TextSearchRequest >() }.getOrNull()
9696 )
97- }.respond()
97+ }.respond(this )
9898 }
9999 }
100100 }
You can’t perform that action at this time.
0 commit comments