Skip to content

Commit 3a26561

Browse files
chore: implement rest-api schema
1 parent 658e3c7 commit 3a26561

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import io.ktor.server.application.call
1313
import io.ktor.server.engine.embeddedServer
1414
import io.ktor.server.netty.Netty
1515
import io.ktor.server.response.respondText
16+
import io.ktor.server.routing.delete
1617
import io.ktor.server.routing.get
18+
import io.ktor.server.routing.patch
19+
import io.ktor.server.routing.post
1720
import io.ktor.server.routing.routing
1821

1922
/**
@@ -45,8 +48,14 @@ class APIController {
4548
private fun roomAPI(app: Application) {
4649
with(app) {
4750
routing {
48-
get("/room") {
49-
call.respondText("[${Thread.currentThread().name}] Room!")
51+
post("$apiPath/rooms") {
52+
call.respondText("[${Thread.currentThread().name}] Room POST!")
53+
}
54+
get("$apiPath/rooms/{room-id}") {
55+
call.respondText("[${Thread.currentThread().name}] Room GET!")
56+
}
57+
delete("$apiPath/rooms/{room-id}") {
58+
call.respondText("[${Thread.currentThread().name}] Room DELETE!")
5059
}
5160
}
5261
}
@@ -59,10 +68,23 @@ class APIController {
5968
private fun medicalTechnologyPI(app: Application) {
6069
with(app) {
6170
routing {
62-
get("/medicaltechnology") {
63-
call.respondText("[${Thread.currentThread().name}] Medical Technology!")
71+
post("$apiPath/medicalTechnologies") {
72+
call.respondText("[${Thread.currentThread().name}] Medical Technology POST!")
73+
}
74+
get("$apiPath/medicalTechnologies/{technology-id}") {
75+
call.respondText("[${Thread.currentThread().name}] Medical Technology GET!")
76+
}
77+
delete("$apiPath/medicalTechnologies/{technology-id}") {
78+
call.respondText("[${Thread.currentThread().name}] Medical Technology DELETE!")
79+
}
80+
patch("$apiPath/medicalTechnologies/{technology-id}") {
81+
call.respondText("[${Thread.currentThread().name}] Medical Technology PATCH!")
6482
}
6583
}
6684
}
6785
}
86+
87+
companion object {
88+
private const val apiPath = "/api"
89+
}
6890
}

0 commit comments

Comments
 (0)