Nav

To Route HTTP Requests to Different Paths

In this procedure, you set up multiple flows, each having an HTTP Listener that listens for requests to different subpaths. The Listeners share a global configuration element (host, port and path). HTTP requests directed to http://localhost:8081/account are routed to the first flow. HTTP requests directed to http://localhost:8081/employee are routed to the second flow. When the Listener global element receives a request that doesn’t match the path defined on any of the HTTP Connector Instances, it returns an HTTP 404 (Resource Not Found).

  1. Create a flow with an HTTP Listener, and set Path to account.

  2. Configure a global element:

    • Set Host to localhost

    • Accept the default Port = 8081.

  3. Add a Logger component to the flow.

  4. Create a second flow.

    • Drag another HTTP Listener to the blank space below the first flow.

    • Select the same connector configuration element as in the other connector.

    • Set Path = employee.

  5. Add a Logger component to the flow.

  6. In a client browser, go to the first URL: http://localhost:8081/account.

  7. In a client browser, go to the second URL: http://localhost:8081/employee.

  8. Verify that the logs show the requests routed to the first and then the second flows, respectively.