General Hooks
This section will show how the general hooks are processed, These hooks include:
- on-receive
- on-generate
- template
- middleware
- validator
Any hook can have other business logic in it e.g A template hook can return the required dynamic data but it may also have logic to do other processes on it. E.g save some data to user session or call another service. A middleware hook might validate some input etc
Consider the example for on-receive
below
The example below works for
on-receive
,on-generate
,middleware
,validator
hooks
Example Hook: On-Receive#
1000:
type: text
on-receive: "rest:https://example.com/api/notify"
message: "Type `yes` to receive a Slack notification from us"
routes:
"yes": "next-stage"
When user responds and on-receive
is defined, the hook is processed.
To define REST API based hooks, prefix them with rest:
Each rest based hook must be a POST request which accepts a HookArgs
object
Consider a sample rest hook
on-receive hook: Notify