First, we've added a request handler. A request handler expects three parameters: The pattern that triggers it, the relative path to a JavaScript file and the name of a function in that file.
Later, we set a property for the file so that it's automatically executed when the server starts. This is what's called a bootstrap file. There are two ways to create a bootstrap file: Change its role (that's what we've done in this example), or put it in a "bootStrap" folder in the solution.
You may have noticed that we pass the function handler by its name. We do not pass the function itself directly. There are two main reasons for this behavior:
This example is basic. In a real life application, you will probably split your handlers into different .js files and have one "bootStrap" file containing several calls to addHttpRequestHandler(). And it is likely that you don't want to load all the scripts for each request.
Also, when the request is handled, Wakanda server must generate a JavaScript execution context (holding the variables, the sessionStorage, etc.), and this can't be done at the time addHttpRequestHandler() is called (because it is called when the server starts up, there is no client-context at this time)