May 2019
Beginner to intermediate
466 pages
10h 44m
English
This is the third step. Going back to our WebApp module (in WebApp.jl), let's continue with the logic for the newgamepage handler. The implementation will look like this:
using ..GameSession, ..Wikipedia, ..Wikipedia.Articles const newgamepage = HTTP.HandlerFunction() do req game = parse(UInt8, (replace(req.target, "/new/"=>""))) |> newgamesession article = game.articles[1] push!(game.history, article) HTTP.Messages.Response(200, wikiarticle(article)) end
Once we create a new game, we need to reference its first article. We add the starting article to the game's history and then we render it as HTML using the following wikiarticle function:
function wikiarticle(article) html = """ <!DOCTYPE ...
Read now
Unlock full access