Home Manual Reference Source Test API Healthcheck

Controllers

Controllers are functions that handle requests to specific endpoint paths:

function controllerFunction(request) {
    ... do stuff and return a message ...
}

The first parameter passed in is the HapiRequest object

We define the mapping from endpoint/method to controller function with an JSON object:

const map1 = {
  path: "/endpoint",
  method: "GET", ///
  controller: controllerFunction
}

To make this endpoint available to the server, we need to export an array of these mappings:

export default [ map1, map2, ... ];

Notes/Ideas