Handlers on each endpoint define Gateway behavior in Formata via JSON. Each endpoint can have 6 optional handlers: GET, POST, PUT, PATCH, DELETE, and HEAD. These handlers are directly connected to the type of request the endpoint gets, GET request maps to the GET handler and so on.
Each handler provides a “pipeline” that the Gateway uses to perform actions, get data, etc… The best way to get started is with examples.
The classic “Hello, world!” GET request handler:
{
"pipeline": [
{
"message": "Hello, world!"
}
]
}
This is the simplest handler in Formata. In this GET handler, we are instructing the Gateway to respond with a JSON object that has a “message” field with the value “Hello, world!”. To test, I’ve made a Space with a path name “cj” and an endpoint with version “v1” on the API named “test” with a path of “hello”.
Response:
curl <https://api.formata.io/cj/v1/test/hello>
{"message": "Hello, world!"}