diff --git a/README.md b/README.md index e09c273..56ce866 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ repositories { ``` - Add the dependency ``` -implementation 'com.github.DaikonWeb:daikon:0.5.2' +implementation 'com.github.DaikonWeb:daikon:0.6.0' ``` ### Maven @@ -40,7 +40,7 @@ implementation 'com.github.DaikonWeb:daikon:0.5.2' com.github.DaikonWeb daikon - 0.5.2 + 0.6.0 ``` diff --git a/build.gradle b/build.gradle index 5c3c04e..ab1b6a1 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'com.github.fracassi-marco' -version '0.5.2' +version '0.6.0' repositories { mavenCentral() diff --git a/src/main/kotlin/daikon/DefaultRouteAction.kt b/src/main/kotlin/daikon/DefaultRouteAction.kt index a026b9d..dced03d 100644 --- a/src/main/kotlin/daikon/DefaultRouteAction.kt +++ b/src/main/kotlin/daikon/DefaultRouteAction.kt @@ -8,7 +8,7 @@ class DefaultRouteAction : RouteAction { override fun handle(request: Request, response: Response) { if (request.method() == GET && request.path() == "/") { response.status(OK_200) - response.content("text/html") + response.type("text/html") response.write(html()) } else { response.status(NOT_FOUND_404) diff --git a/src/main/kotlin/daikon/HttpResponse.kt b/src/main/kotlin/daikon/HttpResponse.kt index c0d3455..ae2129b 100644 --- a/src/main/kotlin/daikon/HttpResponse.kt +++ b/src/main/kotlin/daikon/HttpResponse.kt @@ -19,8 +19,8 @@ class HttpResponse(private val response: HttpServletResponse) : Response { header("Location", path) } - override fun content(type: String) { - response.contentType = type + override fun type(contentType: String) { + response.contentType = contentType } override fun status(code: Int) { diff --git a/src/main/kotlin/daikon/Response.kt b/src/main/kotlin/daikon/Response.kt index 62d4a91..c78b3c9 100644 --- a/src/main/kotlin/daikon/Response.kt +++ b/src/main/kotlin/daikon/Response.kt @@ -5,7 +5,7 @@ import org.eclipse.jetty.http.HttpStatus.MOVED_TEMPORARILY_302 interface Response { fun write(text: String) fun status(code: Int) - fun content(type: String) + fun type(contentType: String) fun header(name: String, value: String) fun body(): String fun redirect(path: String, status: Int = MOVED_TEMPORARILY_302) diff --git a/src/test/kotlin/daikon/DefaultRouteActionTest.kt b/src/test/kotlin/daikon/DefaultRouteActionTest.kt index 914a838..cfccbee 100644 --- a/src/test/kotlin/daikon/DefaultRouteActionTest.kt +++ b/src/test/kotlin/daikon/DefaultRouteActionTest.kt @@ -29,7 +29,7 @@ class DefaultRouteActionTest { DefaultRouteAction().handle(request, response) verify(response).status(OK_200) - verify(response).content("text/html") + verify(response).type("text/html") verify(response).write(contains("You are eating a Daikon!!")) } } \ No newline at end of file diff --git a/src/test/kotlin/daikon/ResponseTest.kt b/src/test/kotlin/daikon/ResponseTest.kt index 7a95d6d..d878ca6 100644 --- a/src/test/kotlin/daikon/ResponseTest.kt +++ b/src/test/kotlin/daikon/ResponseTest.kt @@ -1,7 +1,6 @@ package daikon import daikon.Localhost.get -import daikon.Localhost.post import org.assertj.core.api.Assertions.assertThat import org.eclipse.jetty.http.HttpStatus.CREATED_201 import org.eclipse.jetty.http.HttpStatus.MOVED_PERMANENTLY_301 @@ -21,7 +20,7 @@ class ResponseTest { @Test fun `content type`() { HttpServer() - .any("/") { _, res -> res.content("application/json") } + .any("/") { _, res -> res.type("application/json") } .start().use { assertThat(get("/").headers["Content-Type"]).isEqualTo("application/json") }