Skip to content

Commit

Permalink
Rename content to type
Browse files Browse the repository at this point in the history
  • Loading branch information
fracassi-marco committed Dec 4, 2019
1 parent 26dda2b commit 5abff3e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,7 +40,7 @@ implementation 'com.github.DaikonWeb:daikon:0.5.2'
<dependency>
<groupId>com.github.DaikonWeb</groupId>
<artifactId>daikon</artifactId>
<version>0.5.2</version>
<version>0.6.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = 'com.github.fracassi-marco'
version '0.5.2'
version '0.6.0'

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/daikon/DefaultRouteAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/daikon/HttpResponse.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/daikon/Response.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/daikon/DefaultRouteActionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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!!"))
}
}
3 changes: 1 addition & 2 deletions src/test/kotlin/daikon/ResponseTest.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")
}
Expand Down

0 comments on commit 5abff3e

Please sign in to comment.