For the solution page, the only thing we need from the Request URI is the session ID. Then, we follow the same workflow to get the current Game object. Once we have it, we copy the list of articles into the history stack to display the game's solution using the existing rendering logic. We also set the steps_taken counter to the maximum because the game is considered a loss. Finally, we display the last article:
const solutionpage = HTTP.HandlerFunction() do req uri_parts = parseuri(req.target) game = gamesession(uri_parts[1]) game.history = game.articles game.steps_taken = Gameplay.MAX_NUMBER_OF_STEPS article = game.articles[end]
HTTP.Messages.Response(200, wikiarticle(game, article)) end
The solution page appears as follows, settling the game as a loss: