Skip to content

Commit 996b65b

Browse files
refactor: simplify logic in medical technology creation api
1 parent 7d2ec1d commit 996b65b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/main/kotlin/infrastructure/api/MedicalTechnologyApi.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,14 @@ fun Application.medicalTechnologyAPI(apiPath: String, port: Int, provider: Manag
4949
provider.medicalTechnologyDatabaseManager
5050
)
5151
).execute().apply {
52-
when (this) {
53-
null -> call.respond(HttpStatusCode.Conflict)
54-
else -> {
55-
call.response.header(
56-
HttpHeaders.Location,
57-
"http://localhost:$port$apiPath/medical-technologies/${medicalTechnology.id.value}"
58-
)
59-
call.respond(HttpStatusCode.Created)
60-
}
52+
if (this == null) {
53+
call.respond(HttpStatusCode.Conflict)
54+
} else {
55+
call.response.header(
56+
HttpHeaders.Location,
57+
"http://localhost:$port$apiPath/medical-technologies/${medicalTechnology.id.value}"
58+
)
59+
call.respond(HttpStatusCode.Created)
6160
}
6261
}
6362
}

0 commit comments

Comments
 (0)