Appearance
Route
Routes are at the core of foreq. They act as an intermidiary between a client and a resource server, taking requests from the client creating it with the provided configuration and forwarding them to the configured destination.
Configuration
Endpoint
The complete url used to access a resource. The endpoint contains the user provided subdomain and route
Eg: POST: https://project_subdomain.api.foreq.dev/p/route_name
Label
User provided string used to quickly identify a route
Destination
This is the 3rd party API's endpoint which has the desired resource. It consists of the request method(applicable only to http, websockets, server-sent events) and the endpoint's url.
Headers
The request headers to use when making the request to the destination. The expected format is JSON, which can be static or with values dynamically added in through secrets and arguments. For SMTP requests the header is static and requires the standard headers for an SMTP request.
HTTP header example
json
{
"Authorization": "Basic ${secrets.API_TOKEN}",
"X-From-Browser": "${args.BROWSER_ORIGIN}",
"X-Static-Header": "some.value.that.is.static"
}
SMTP header example
json
{
"host": "smtp.gmail.com",
"port": 587,
"username": "username",
"password": "${secrets.GMAIL_PASSWORD}"
}
Body
This section consists of two parts. The first is a checkbox “Use body from incoming request when using endpoint”. When this is checked, this allows the client to provide the request body that’ll be forwarded to the destination. When the incoming body is JSON it should have the format:
json
{
"args": {},
"body": {},
}
Where args is short for arguments and they are values that can be dynamically inserted into headers, look at the Arguments section for more detail, and body the is the actual request body that is forwarded. NOTE: this only works for JSON, if the incoming request is a multipart form the entire body is forwarded.
Eg of a provided request body
json
{
"firstname": "${args.firstname}",
"secret": "${secret.USER_SECCRET}"
}
Suppose the endpoint for this route is https://demo.api.foreq.dev/p/fetch-body
. When a request is made to the endpoint with the request body.
json
{
"args": {
"firstname": "john"
}
}
Supposing a secret was likewise created in the project settings section with the key USER_SECRET
with the value super_duper_secret
. The request body that'll be forwarded by foreq would be:
json
{
"firstname": "john",
"secret": "super_super_secret"
}
Logs
A page to inspect and analyse all requests made to a route.