---
schema_version: "1"
id: 48494d36c09b5a96c10c37eddebf06c73432dffd85abe2924ea7eef1175e307a
title: Route HTTP Requests to Different Paths Example
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/http-connector/1.11/http-conn-route-diff-paths-task.md
canonical_url: https://docs.mulesoft.com/http-connector/1.11/http-conn-route-diff-paths-task
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 37604596de87e930c53178ad2e22e5f5b732443ab628c3575b0a904258d6326e
description: MuleSoft Documentation Site
release: "1.11"
latest: false
---
---
product: HTTP Connector
version: 1.11
---

# Route HTTP Requests to Different Paths Example

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

The following example has multiple flows, each having an Anypoint Connector for HTTP (HTTP
Connector) **Listener** source that listens for requests to different subpaths:

- 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.

- HTTP requests that don’t match the path defined in any of the HTTP Listeners make the connector
  return an HTTP `404 Resource Not Found` error.

To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and
test the app with curl commands.

The following screenshot shows the Anypoint Studio app flow for this example:

![HTTP Requests to paths flow](/mulesoft/current/en-us/http-connector/1.11/_images/request-mule-msg-map.png)

## Create the Mule Application

To create the Mule flow:

1.  In the **Mule Palette** view, select the HTTP **Listener** source and drag it onto the canvas.  
    The source initiates the flow by listening for incoming HTTP message attributes.

2.  Set the **Path** field to `account` to start the app from the web browser.

3.  Click the plus sign (**+**) next to the **Connector configuration** field to configure a global
    element that can be used by all instances of the HTTP **Listener** in the app.

4.  On the **General** tab, configure the following fields:

    - **Host**: `localhost`

    - **Port**: `8081`

5.  Click **OK**.

    ![HTTP Listener global configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-route-example-1.png)

    ![HTTP Listener configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-route-example-2.png)

6.  Drag a **Logger** component to the right of the HTTP **Listener** source.

7.  To create the second flow, drag another HTTP **Listener** below the first flow.

8.  For the **Connector configuration** field, select the same `HTTP_Listener_config` configuration
    created for the first HTTP **Listener** source.

9.  Set **Path** to `employee`.

    ![HTTP Listener configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-route-example-2.png)

10. Drag a **Logger** component to the right of the second HTTP **Listener** source.

11. Save your Mule app.

12. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule
    Application**.

13. Open a browser window and type the first URL: `http://localhost:8081/account`.

14. Open another browser window and type the second URL: `http://localhost:8081/employee`.

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

## XML for Routing HTTP Requests

Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule
app:

```xml
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
	<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" >
		<http:listener-connection host="localhost" port="8081" />
	</http:listener-config>
	<flow name="Flow1" >
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="path"/>
		<logger level="INFO" doc:name="Logger" />
	</flow>
	<flow name="Flow2" >
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="employee"/>
		<logger level="INFO" doc:name="Logger" />
	</flow>
</mule>
```

## See Also

- [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors)

- [Salesforce Help](https://help.salesforce.com)
