Create route to list all the games
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package eventDemo.adapter.interfaceLayer
|
||||
|
||||
import eventDemo.business.event.projection.gameList.GameListRepository
|
||||
import io.ktor.resources.Resource
|
||||
import io.ktor.server.application.call
|
||||
import io.ktor.server.auth.authenticate
|
||||
import io.ktor.server.resources.get
|
||||
import io.ktor.server.response.respond
|
||||
import io.ktor.server.routing.Route
|
||||
import io.ktor.server.routing.get
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@Resource("/games")
|
||||
class Games
|
||||
|
||||
/**
|
||||
* API routes to show all games.
|
||||
*/
|
||||
fun Route.readGamesList(gameListRepository: GameListRepository) {
|
||||
authenticate {
|
||||
// Read the last played card on the game.
|
||||
get<Games> {
|
||||
val gameList = gameListRepository.getList()
|
||||
call.respond(gameList)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import io.ktor.server.routing.Route
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@Resource("/game/{id}")
|
||||
@Resource("/games/{id}")
|
||||
class Game(
|
||||
@Serializable(with = GameIdSerializer::class)
|
||||
val id: GameId,
|
||||
|
||||
Reference in New Issue
Block a user