Skip to content

Commit c0786dd

Browse files
fix: add content type to http server responses
1 parent 6a94289 commit c0786dd

File tree

8 files changed

+32
-18
lines changed

8 files changed

+32
-18
lines changed

src/main/kotlin/infrastructure/api/handlers/BlockHealthProfessionalTrackingHandler.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ package infrastructure.api.handlers
1111
import application.presenter.api.tracking.toTrackingInfoDto
1212
import application.service.TrackingService
1313
import infrastructure.provider.Provider
14+
import io.netty.handler.codec.http.HttpResponseStatus
1415
import io.vertx.core.CompositeFuture
1516
import io.vertx.core.Handler
1617
import io.vertx.ext.web.RoutingContext
@@ -33,7 +34,10 @@ class BlockHealthProfessionalTrackingHandler(
3334
val block = list.map { hp ->
3435
hp.result().toTrackingInfoDto()
3536
}
36-
routingContext.response().end(Json.encodeToString(block))
37+
routingContext.response()
38+
.putHeader("content-type", "application/json")
39+
.setStatusCode(HttpResponseStatus.OK.code())
40+
.end(Json.encodeToString(block))
3741
}
3842
}
3943
}

src/main/kotlin/infrastructure/api/handlers/ProcessInfoHandler.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class ProcessInfoHandler(
3535
provider.webClient,
3636
).execute().onSuccess { surgicalProcess ->
3737
if (surgicalProcess != null) {
38-
routingContext.response().setStatusCode(HttpResponseStatus.OK.code()).end(
39-
Json.encodeToString(surgicalProcess.toSurgicalProcessDto()),
40-
)
38+
routingContext.response().setStatusCode(HttpResponseStatus.OK.code())
39+
.putHeader("content-type", "application/json")
40+
.end(Json.encodeToString(surgicalProcess.toSurgicalProcessDto()))
4141
} else {
4242
routingContext.response().setStatusCode(HttpResponseStatus.NO_CONTENT.code()).end()
4343
}

src/main/kotlin/infrastructure/api/handlers/ProcessStateHandler.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ class ProcessStateHandler(
3333
provider.webClient,
3434
).execute().onSuccess { surgicalProcess ->
3535
if (surgicalProcess != null) {
36-
routingContext.response().setStatusCode(HttpResponseStatus.OK.code()).end(
37-
Json.encodeToString(
38-
ProcessStateInfoDto(
39-
surgicalProcess.state.toString(),
40-
surgicalProcess.step.toString(),
36+
routingContext.response().setStatusCode(HttpResponseStatus.OK.code())
37+
.putHeader("content-type", "application/json")
38+
.end(
39+
Json.encodeToString(
40+
ProcessStateInfoDto(
41+
surgicalProcess.state.toString(),
42+
surgicalProcess.step.toString(),
43+
),
4144
),
42-
),
43-
)
45+
)
4446
} else {
4547
routingContext.response().setStatusCode(HttpResponseStatus.NO_CONTENT.code()).end()
4648
}

src/main/kotlin/infrastructure/api/handlers/RoomInfoHandler.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class RoomInfoHandler(
3333
).execute().onSuccess { room ->
3434
routingContext.response()
3535
.setStatusCode(HttpResponseStatus.OK.code())
36+
.putHeader("content-type", "application/json")
3637
.end(
3738
Json.encodeToString(room.toRoomDto()),
3839
)

src/main/kotlin/infrastructure/api/handlers/SurgeryReportInfoHandler.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class SurgeryReportInfoHandler(
3232
routingContext
3333
.response()
3434
.setStatusCode(HttpResponseStatus.OK.code())
35+
.putHeader("content-type", "application/json")
3536
.end(
3637
Json.encodeToJsonElement(report.toApiDto()).toString(),
3738
)

src/main/kotlin/infrastructure/api/handlers/SurgeryReportsArchiveHandler.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ class SurgeryReportsArchiveHandler(
2929
reports.map { report ->
3030
report.toSurgeryReportEntryDto()
3131
}.run {
32-
routingContext.response().setStatusCode(HttpResponseStatus.OK.code()).end(
33-
Json.encodeToString(this),
34-
)
32+
routingContext.response().setStatusCode(HttpResponseStatus.OK.code())
33+
.putHeader("content-type", "application/json")
34+
.end(
35+
Json.encodeToString(this),
36+
)
3537
}
3638
}
3739
}

src/main/kotlin/infrastructure/api/handlers/ZoneHealthProfessionalTrackingHandler.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ class ZoneHealthProfessionalTrackingHandler(
4545
val preOperating = result.second.result().map { hp ->
4646
hp.result().toTrackingInfoDto()
4747
}
48-
routingContext.response().end(Json.encodeToString(operating + preOperating))
48+
routingContext.response()
49+
.putHeader("content-type", "application/json")
50+
.end(Json.encodeToString(operating + preOperating))
4951
}
5052
}
5153
}

src/main/kotlin/infrastructure/api/handlers/ZonesHandler.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ class ZonesHandler(
4141
}?.id?.id,
4242
)
4343
}.run {
44-
routingContext.response().setStatusCode(HttpResponseStatus.OK.code()).end(
45-
Json.encodeToString(this),
46-
)
44+
routingContext.response().setStatusCode(HttpResponseStatus.OK.code())
45+
.putHeader("content-type", "application/json")
46+
.end(
47+
Json.encodeToString(this),
48+
)
4749
}
4850
}
4951
}

0 commit comments

Comments
 (0)