org.mule.modules

mule-module-rest


Namespacehttp://www.mulesoft.org/schema/mule/rest
Schema Locationhttp://www.mulesoft.org/schema/mule/rest/current/mule-rest.xsd  (View Schema)
Schema Version1.0
Minimum Mule Version3.2

Module Overview

A Mule module for implementing REST APIs whitin flows.

The module includes a custom router that will dispatch the message to the inner message processors as long as the URI matches and the processors are attached to the right HTTP method.

Summary

Message Processors
<rest:router>
A REST router is an intercepting message processor that will only execute if the incoming message contains a http.request.path property that matches the templareUri parameter.

Configuration

To use the this module within a flow the namespace to the module must be included. The resulting flow will look similar to the following:

<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:rest="http://www.mulesoft.org/schema/mule/rest"
      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/rest
               http://www.mulesoft.org/schema/mule/rest/current/mule-rest.xsd">

      <!-- here goes your flows and configuration elements -->

</mule>

Message Processors

<rest:router>

A REST router is an intercepting message processor that will only execute if the incoming message contains a http.request.path property that matches the templareUri parameter.

An URI template is a URI-like String that contained variables marked of in braces ({, }), which can be expanded to produce a URI.

The following is an example URI template:

/hotels/{hotel}/bookings/{booking}

If the incoming URI matches the template it will extract the variables in it and it will make them available as properties.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescription
config-ref Optional. Specify which configuration to use.
templateUri Template URI string. Variables need to be contained within braces {, }.
method The HTTP method of the request
uri The HTTP uri of the request
sourceCallback The source callback
Child Elements
<rest:get>
Optional. Processor to be executed when the HTTP method is "GET"
<rest:put>
Optional. Processor to be executed when the HTTP method is "PUT"
<rest:post>
Optional. Processor to be executed when the HTTP method is "POST"
<rest:delete>
Optional. Processor to be executed when the HTTP method is "DELETE"
<rest:patch>
Optional. Processor to be executed when the HTTP method is "PATCH"
Return Payload
  • Object
Exception Payloads
Payload ClassDescription
UnsupportedHttpVerbException Thrown when the HTTP method is not available or when the processor to be executed is null.
Exception