public class

RestModule

extends Object
java.lang.Object
   ↳ org.mule.modules.rest.RestModule
Known Direct Subclasses
Known Indirect Subclasses

Class 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

Constants
String VALUE_REGEX Replaces template variables in the URI template.
Fields
private static final Logger LOGGER
private static final Pattern NAMES_PATTERN Captures URI template variable names.
Public Constructors
RestModule()
Public Methods
Object router(String templateUri, NestedProcessor get, NestedProcessor put, NestedProcessor post, NestedProcessor delete, NestedProcessor patch, String method, String uri, InterceptCallback cont)
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.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

private static final String VALUE_REGEX

Replaces template variables in the URI template.

Constant Value: "(.*)"

Fields

private static final Logger LOGGER

private static final Pattern NAMES_PATTERN

Captures URI template variable names.

Public Constructors

public RestModule ()

Public Methods

public Object router (String templateUri, NestedProcessor get, NestedProcessor put, NestedProcessor post, NestedProcessor delete, NestedProcessor patch, String method, String uri, InterceptCallback cont)

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.

Java Sample
INCLUDE_ERROR

Parameters
templateUri Template URI string. Variables need to be contained within braces {, }.
get Processor to be executed when the HTTP method is "GET"
put Processor to be executed when the HTTP method is "PUT"
post Processor to be executed when the HTTP method is "POST"
delete Processor to be executed when the HTTP method is "DELETE"
patch Processor to be executed when the HTTP method is "PATCH"
method The HTTP method of the request
uri The HTTP uri of the request
cont Callback to be executed if the URI does not match
Returns
  • Object
Throws
UnsupportedHttpVerbException Thrown when the HTTP method is not available or when the processor to be executed is null.
Exception