org.mule.modules

mule-module-rest

config

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

Configuration
<rest:config>
Configure an instance of this module
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 ValueDescriptionJava TypeMIME TypeEncoding
config-ref Optional. Specify which configuration to use.
templateUri Template URI string. Variables need to be contained within braces {, }. String */* UTF-8
method The HTTP method of the request String */* UTF-8
uri The HTTP uri of the request String */* UTF-8
sourceCallback The source callback SourceCallback */*
Child Elements
NameDefault ValueDescriptionJava Type
<rest:get> Optional. Processor to be executed when the HTTP method is "GET" NestedProcessor
<rest:put> Optional. Processor to be executed when the HTTP method is "PUT" NestedProcessor
<rest:post> Optional. Processor to be executed when the HTTP method is "POST" NestedProcessor
<rest:delete> Optional. Processor to be executed when the HTTP method is "DELETE" NestedProcessor
<rest:patch> Optional. Processor to be executed when the HTTP method is "PATCH" NestedProcessor
Returns
Return Type Description
Object Object
Exception Payloads
Payload ClassDescription
UnsupportedHttpVerbException Thrown when the HTTP method is not available or when the processor to be executed is null.
Exception Thrown when something goes wrong processing the request.

Message Sources

Transformers