The Process Request Data Into Header solution is a serverless solution available at Azion Marketplace.
The purpose of this function is to stop a request whenever a request body field is empty. Using regex, the user can validate not only whether the field exists but also patterns. Additionally, they have the option to use any behavior they choose rather than a predetermined
Getting the solutionSection titled Getting the solution
To install the solution, follow these steps:
- Log in to your Real-Time Manager (RTM) account.
- If you don’t have an account, you can create one here.
- On the upper-left corner of the page, select Products menu > Marketplace.
- Select the search box and type “request” or browse through the cards to find the Process Request Data Into Header solution.
- Once you’ve found the solution’s card, select it to go to the solution’s page.
- On the solution’s page, look for the Subscribe for section on the bottom-right corner.
- Click the Get It Now button.
After clicking on the Get it now button, you’ll see a message indicating that your solution was successfully installed and is ready to use.
Using the solutionSection titled Using the solution
Setting up the Edge Firewall ruleSection titled Setting up the Edge Firewall rule
To instantiate the Process Request Data Into Header solution, follow the steps:
- On RTM, on the Products menu, select Edge Firewall in the SECURE section.
- Click the Add Rule Set button.
- Give an easy to remember name to your new rule.
- Select the domains you want to protect with the function.
- Turn the Edge Functions switch on.
- Click the Save button.
Done. Now you have instantiated the rule for your function.
Setting up the solutionSection titled Setting up the solution
To instantiate the Process Request Data Into Header solution, while still on the Edge Firewall page, select the Functions tab and follow these steps:
- Click the Add Function button.
- Give an easy to remember name to your instance.
- On the dropdown menu, select the Process Request Data Into Header function.
This action will load the function, showing a form with the function’s source code and, just above it, two tabs: Code and Args. By clicking the Code tab, you’ll be able to navigate through the source code but won’t be able to change it. Also, this function doesn’t address any argument on the Args tab, but you can test it using the
Curl command examplesSection titled Curl command examples
|Curl Command||Request headers added by the function|
Important: as long as the request has a valid
Content-Typeheader and a valid request body, the solution converts the body fields into headers. This solution also supports nested object data; in this case, each “level” will be separated by a hyphen.
Possible errorsSection titled Possible errors
This solution can trigger errors; in this case, the errors will be appended to a new header called
|The header |
|The header |
|The request body isn’t correctly formatted and couldn’t be decoded.|
Setting up the Edge Firewall Rules EngineSection titled Setting up the Edge Firewall Rules Engine
To finish, you have to set up the Rules Engine to configure the behavior and the criteria to run the solution.
Still in the Edge Firewall page, select the Rules Engine tab and follow these steps:
- Click the New Rule button.
- Name your rule something easy to remember.
- Select a criteria to run and catch the domain you want to run the solution on.
- Below, select a behavior to the criteria. In this case, it’ll be Run Function. Then, select the adequate Process Request Data Into Header function, according to the name you gave it in the instantiate step.
- Click the Save button.
Done. Now the Process Request Data Into Header solution is running for every request made to the domain you indicated.