Hooks
Server hooks to handle Pre and Post requests
Overview
Hooks allows us to handle request based on the request method and URI pattern.
Types
There are two types of hooks - Before and After, each type will apply first or last in order based on the type.
BeforeHook
The before hook will apply first, before any middleware will take place
AfterHook
The after hook will apply last, after the request ends and response returned to the client.
Usage
Basic usage
The Before and After hooks use as decorator for method
Hook should be end by calling to the next
method
Example
Priority
We can control the order of hooks apply be setting the hook priority.
Lower the number is, hook priority is higher and will apply earlier
Example
Last updated