Repository: ktorio/ktor
File: ktor-server/ktor-server-tests/common/test/io/ktor/tests/server/routing/RoutingProcessingTest.kt (Kotlin)

Code before:
        on("making request to /headerFirst with `param` query parameter and accept header") {
            client.get("/headerFirst?param=value") {
                header(HttpHeaders.Accept, "text/plain")
            }
            it("should choose header routing") {
                assertEquals(selectedRoute, SelectedRoute.Header)
            }
        }
    }

    @Test
    fun testRoutingAcceptContentSubtypeWildcard() = testApplication {

        routing {
            route("getImage") {
                accept(ContentType.Image.Any) {
                    get { call.respondText { "Image" } }
                }
            }
        }

        on("making request to /getImage with Accept image/png") {
            client.get("/getImage") {
                header(HttpHeaders.Accept, "image/png")
            }
            .let {
                assertEquals(HttpStatusCode.OK, it.status)
                assertEquals("Image", it.bodyAsText())
            }
        }
    }

    @Test
    fun testMostSpecificSelected() = testApplication {
        var path = ""
        routing {
            get("{path...}") {
                path = call.parameters.getAll("path")?.joinToString("/") ?: "/"
            }
            get("z/{path...}") {
                path = "[Z] " + (call.parameters.getAll("path")?.joinToString("/") ?: "/")
            }
        }
        on("making get request to /z/a/b/c") {
            client.get("/z/a/b/c")
            it("should have handled by more specific route") {
                assertEquals("[Z] a/b/c", path)
            }
        }
        on("making get request to /x/a/b/c") {
            client.get("/x/a/b/c")

Review comment (suggestion):
Our linter complains about indents in this file. this change should fix the problem. It also doesn't like the first empty line in the function body.

```suggestion
            }.let {
```

Code after:
        on("making request to /headerFirst with `param` query parameter and accept header") {
            client.get("/headerFirst?param=value") {
                header(HttpHeaders.Accept, "text/plain")
            }
            it("should choose header routing") {
                assertEquals(selectedRoute, SelectedRoute.Header)
            }
        }
    }

    @Test
    fun testRoutingAcceptContentSubtypeWildcard() = testApplication {
        routing {
            route("image") {
                accept(ContentType.Image.Any) {
                    get { call.respondText { "Image" } }
                }
            }
            route("any") {
                accept(ContentType.Any) {
                    get { call.respondText { "Any" } }
                }
            }
        }

        on("making request to /image with Accept image/png") {
            client.get("/image") {
                header(HttpHeaders.Accept, ContentType.Image.PNG)
            }.let {
                assertEquals(HttpStatusCode.OK, it.status)
                assertEquals("Image", it.bodyAsText())
            }
        }

        on("making request to /image with Accept */*") {
            client.get("/image") {
                header(HttpHeaders.Accept, ContentType.Any)
            }.let {
                assertEquals(HttpStatusCode.OK, it.status)
                assertEquals("Image", it.bodyAsText())
            }
        }

        on("making request to /any with Accept image/png") {
            client.get("/any") {
                header(HttpHeaders.Accept, ContentType.Image.PNG)
            }.let {
                assertEquals(HttpStatusCode.OK, it.status)
                assertEquals("Any", it.bodyAsText())
            }
        }