May 2019
Beginner to intermediate
466 pages
10h 44m
English
This is the very first step. Remember that within our HandlerFunction, we have access to the Request object, req. All the Request objects expose a field called target that references the URL of the request. The target does not include the protocol or the domain name, so it will be of the form /new/$difficulty_level. A quick way to extract the value of $difficulty_level is to simply replace the first part of the URI with an empty string, "", effectively removing it. The result will be used in a function, newgamesession, to create a new game of the indicated difficulty. Put into code, it will look like this:
game = parse(UInt8, (replace(req.target, "/new/"=>""))) |> newgamesession
Since ...
Read now
Unlock full access