In the various life cycle events in hapi, such as authentication, route handlers, route prerequisites, you will see reply as one of the function arguments. This is the reply interface.
Throughout this book and the API documentation, you will see the function reply in two forms—either as reply()
or as reply.continue()
—which have two different purposes. reply.continue()
is generally used to return the control flow back to the framework and continue through the request life cycle, whereas reply()
is generally used to generate the response to be returned to the client. The only exception to this is inside the route prerequisites where reply()
is used, as it assigns a variable to the request.pre
object.
reply()
can accept two parameters (error and response), but this is rarely used, as reply always acts on the first defined parameter that it is passed in. For example, if reply()
is passed two variables and the first one is not null, it treats this as an error reply. If only...