Adding an Event Preprocessor Rule Function

It is a good practice to respond to the incoming event with an outgoing event to complete the HTTP request-response cycle. The event-sending client is the HTML form in the readme for the example project. In this task, you add a rule function to use as a preprocessor to respond to the incoming event with the same event.

Procedure

  1. Right click the RuleFunctions folder, and select New > Rule Function
  2. In the Filename field, type PreProcessor. Click Finish.
  3. In the rule function source editor replace the text with the following text and save the resource:
    /**
     * @description Closes requests from the HTTP server
     */
    void rulefunction RuleFunctions.PreProcessor {
       
       attribute {
          validity = ACTION;
       }
       scope {
          Event request;
          
       }
       body {
          // Replies to the request event, in order to close the HTTP request.
          // To keep it simple, uses the request event as the response.
          Event.replyEvent(request, request);
       }
       
    }