HTTP Static Resource Handler in Mule | Load Static File in Mule
We can configure the HTTP connector to load a static resource, such as your home page or a script. You set the path and file name of a resource to load. You optionally set the name of another file in the same directory as the resource to use in case of failure.
flow of HTTP Static Resource Handler :
In above flow we are loading a static html file demo.html kept in src/main resources and will display static content : Hi everyone...
HTTP Static Resource Handler Configuration :
URL : http://localhost:8085/api/static Method : GET
Output :
XML project code :
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:s3="http://www.mulesoft.org/schema/mule/s3" xmlns:anypoint-mq="http://www.mulesoft.org/schema/mule/anypoint-mq" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:ajax="http://www.mulesoft.org/schema/mule/ajax" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
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://www.mulesoft.org/schema/mule/ajax http://www.mulesoft.org/schema/mule/ajax/current/mule-ajax.xsd
http://www.mulesoft.org/schema/mule/anypoint-mq http://www.mulesoft.org/schema/mule/anypoint-mq/current/mule-anypoint-mq.xsd
http://www.mulesoft.org/schema/mule/s3 http://www.mulesoft.org/schema/mule/s3/current/mule-s3.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8085" basePath="/api" doc:name="HTTP Listener Configuration"/>
<flow name="test_staticresourcehandler">
<http:listener config-ref="HTTP_Listener_Configuration" path="/static" doc:name="HTTP"/>
<http:static-resource-handler resourceBase="src/main/resources/demo.html" defaultFile="src/main/resources/demo.html" doc:name="HTTP Static Resource Handler"/>
<logger message="Completed............" level="INFO" doc:name="Logger"/>
</flow>
</mule>
No comments:
Post a Comment