public abstract class DefaultRouteBuilder extends Object implements RouteBuilder
RouteBuilder.UriNamingStrategy
Modifier and Type | Field and Description |
---|---|
static RouteBuilder.UriNamingStrategy |
CAMEL_CASE_NAMING_STRATEGY
A
RouteBuilder.UriNamingStrategy where by camel case conventions are used. |
protected ConversionService<?> |
conversionService |
protected Charset |
defaultCharset |
protected ExecutionHandleLocator |
executionHandleLocator |
protected static org.slf4j.Logger |
LOG |
protected RouteBuilder.UriNamingStrategy |
uriNamingStrategy |
ID
Constructor and Description |
---|
DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator) |
DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator,
RouteBuilder.UriNamingStrategy uriNamingStrategy) |
DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator,
RouteBuilder.UriNamingStrategy uriNamingStrategy,
ConversionService<?> conversionService) |
Modifier and Type | Method and Description |
---|---|
FilterRoute |
addFilter(String pathPattern,
BeanLocator beanLocator,
BeanDefinition<? extends HttpFilter> beanDefinition)
Add a filter.
|
FilterRoute |
addFilter(String pathPattern,
Supplier<HttpFilter> filter)
Add a filter.
|
protected UriRoute |
buildBeanRoute(String httpMethodName,
HttpMethod httpMethod,
String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
A special case that is required for non standard http methods.
|
protected UriRoute |
buildRoute(HttpMethod httpMethod,
String uri,
Class<?> type,
String method,
Class... parameterTypes)
Build a route.
|
protected UriRoute |
buildRoute(HttpMethod httpMethod,
String uri,
MethodExecutionHandle<?,Object> executableHandle)
Build a route.
|
UriRoute |
DELETE(String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
DELETE(String uri,
Class type,
String method,
Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
DELETE(String uri,
Object target,
String method,
Class... parameterTypes)
Route the specified URI template to the specified target.
|
ErrorRoute |
error(Class<? extends Throwable> error,
Class type,
String method,
Class[] parameterTypes)
Register a route to handle the error.
|
ErrorRoute |
error(Class originatingClass,
Class<? extends Throwable> error,
Class type,
String method,
Class[] parameterTypes)
Register a route to handle the error.
|
UriRoute |
GET(String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
GET(String uri,
Class<?> type,
String method,
Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
GET(String uri,
Object target,
String method,
Class... parameterTypes)
Route the specified URI template to the specified target.
|
List<ErrorRoute> |
getErrorRoutes() |
Set<Integer> |
getExposedPorts() |
List<FilterRoute> |
getFilterRoutes() |
List<StatusRoute> |
getStatusRoutes() |
RouteBuilder.UriNamingStrategy |
getUriNamingStrategy() |
List<UriRoute> |
getUriRoutes() |
UriRoute |
HEAD(String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
HEAD(String uri,
Class type,
String method,
Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
HEAD(String uri,
Object target,
String method,
Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
OPTIONS(String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
OPTIONS(String uri,
Class type,
String method,
Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
OPTIONS(String uri,
Object target,
String method,
Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
PATCH(String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
PATCH(String uri,
Class type,
String method,
Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
PATCH(String uri,
Object target,
String method,
Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
POST(String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
POST(String uri,
Class type,
String method,
Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
POST(String uri,
Object target,
String method,
Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
PUT(String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
PUT(String uri,
Class type,
String method,
Class... parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
PUT(String uri,
Object target,
String method,
Class... parameterTypes)
Route the specified URI template to the specified target.
|
ResourceRoute |
resources(Class cls)
Builds the necessary mappings to treat the given class as a REST endpoint.
|
ResourceRoute |
single(Class cls)
Builds the necessary mappings to treat the given class as a singular REST endpoint.
|
StatusRoute |
status(Class originatingClass,
HttpStatus status,
Class type,
String method,
Class[] parameterTypes)
Register a route to handle the returned status code.
|
StatusRoute |
status(HttpStatus status,
Class type,
String method,
Class[] parameterTypes)
Register a route to handle the returned status code.
|
UriRoute |
TRACE(String uri,
BeanDefinition<?> beanDefinition,
ExecutableMethod<?,?> method)
Route the specified URI template to the specified target.
|
UriRoute |
TRACE(String uri,
Class type,
String method,
Class[] parameterTypes)
Route the specified URI template to the specified target.
|
UriRoute |
TRACE(String uri,
Object target,
String method,
Class[] parameterTypes)
Route the specified URI template to the specified target.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
DELETE, DELETE, DELETE, DELETE, DELETE, DELETE, error, error, error, error, GET, GET, GET, GET, GET, GET, HEAD, HEAD, HEAD, HEAD, HEAD, HEAD, OPTIONS, OPTIONS, OPTIONS, OPTIONS, OPTIONS, OPTIONS, PATCH, PATCH, PATCH, PATCH, PATCH, PATCH, POST, POST, POST, POST, POST, POST, PUT, PUT, PUT, PUT, PUT, PUT, resources, single, status, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE
public static final RouteBuilder.UriNamingStrategy CAMEL_CASE_NAMING_STRATEGY
RouteBuilder.UriNamingStrategy
where by camel case conventions are used.protected static final org.slf4j.Logger LOG
protected final ExecutionHandleLocator executionHandleLocator
protected final RouteBuilder.UriNamingStrategy uriNamingStrategy
protected final ConversionService<?> conversionService
protected final Charset defaultCharset
public DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator)
executionHandleLocator
- The execution handler locatorpublic DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator, RouteBuilder.UriNamingStrategy uriNamingStrategy)
executionHandleLocator
- The execution handler locatoruriNamingStrategy
- The URI naming strategypublic DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator, RouteBuilder.UriNamingStrategy uriNamingStrategy, ConversionService<?> conversionService)
executionHandleLocator
- The execution handler locatoruriNamingStrategy
- The URI naming strategyconversionService
- The conversion servicepublic Set<Integer> getExposedPorts()
getExposedPorts
in interface RouteBuilder
public List<FilterRoute> getFilterRoutes()
getFilterRoutes
in interface RouteBuilder
public FilterRoute addFilter(String pathPattern, Supplier<HttpFilter> filter)
RouteBuilder
addFilter
in interface RouteBuilder
pathPattern
- The path pattern for the filterfilter
- The filter itselfFilterRoute
public FilterRoute addFilter(String pathPattern, BeanLocator beanLocator, BeanDefinition<? extends HttpFilter> beanDefinition)
RouteBuilder
addFilter
in interface RouteBuilder
pathPattern
- The path pattern for the filterbeanLocator
- The bean locatorbeanDefinition
- The bean definitionFilterRoute
public List<StatusRoute> getStatusRoutes()
getStatusRoutes
in interface RouteBuilder
public List<ErrorRoute> getErrorRoutes()
getErrorRoutes
in interface RouteBuilder
public List<UriRoute> getUriRoutes()
getUriRoutes
in interface RouteBuilder
public RouteBuilder.UriNamingStrategy getUriNamingStrategy()
getUriNamingStrategy
in interface RouteBuilder
public ResourceRoute resources(Class cls)
RouteBuilder
Builds the necessary mappings to treat the given class as a REST endpoint.
For example given a class called BookController the following routes will be produced:
GET "/book"
GET "/book{/id}"
POST "/book"
PUT "/book{/id}"
PATCH "/book{/id}"
DELETE "/book{/id}"
By default it is assumed the accepted and returned content type is
MediaType.APPLICATION_JSON_TYPE
.
resources
in interface RouteBuilder
cls
- The classResourceRoute
public ResourceRoute single(Class cls)
RouteBuilder
Builds the necessary mappings to treat the given class as a singular REST endpoint.
For example given a class called BookController the following routes will be produced:
GET "/book"
POST "/book"
PUT "/book"
PATCH "/book"
DELETE "/book"
By default it is assumed the accepted and returned content type is
MediaType.APPLICATION_JSON_TYPE
.
single
in interface RouteBuilder
cls
- The classResourceRoute
public StatusRoute status(Class originatingClass, HttpStatus status, Class type, String method, Class[] parameterTypes)
RouteBuilder
status
in interface RouteBuilder
originatingClass
- The class where the error originates fromstatus
- The status codetype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic StatusRoute status(HttpStatus status, Class type, String method, Class[] parameterTypes)
RouteBuilder
status
in interface RouteBuilder
status
- The status codetype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic ErrorRoute error(Class originatingClass, Class<? extends Throwable> error, Class type, String method, Class[] parameterTypes)
RouteBuilder
error
in interface RouteBuilder
originatingClass
- The class where the error originates fromerror
- The error typetype
- The type to route tomethod
- The method THe method to route toparameterTypes
- The parameter types for the target methodpublic ErrorRoute error(Class<? extends Throwable> error, Class type, String method, Class[] parameterTypes)
RouteBuilder
error
in interface RouteBuilder
error
- The errortype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute GET(String uri, Object target, String method, Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
GET
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute GET(String uri, Class<?> type, String method, Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
GET
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute POST(String uri, Object target, String method, Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
POST
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute POST(String uri, Class type, String method, Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
POST
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute PUT(String uri, Object target, String method, Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
PUT
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute PUT(String uri, Class type, String method, Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
PUT
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute PATCH(String uri, Object target, String method, Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
PATCH
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute PATCH(String uri, Class type, String method, Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
PATCH
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute DELETE(String uri, Object target, String method, Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
DELETE
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute DELETE(String uri, Class type, String method, Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
DELETE
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute OPTIONS(String uri, Object target, String method, Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
OPTIONS
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute OPTIONS(String uri, Class type, String method, Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
OPTIONS
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute HEAD(String uri, Object target, String method, Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
HEAD
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute HEAD(String uri, Class type, String method, Class... parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
HEAD
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute TRACE(String uri, Object target, String method, Class[] parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
TRACE
in interface RouteBuilder
uri
- The URItarget
- The targetmethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute TRACE(String uri, Class type, String method, Class[] parameterTypes)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
TRACE
in interface RouteBuilder
uri
- The URItype
- The typemethod
- The methodparameterTypes
- The parameter types for the target methodpublic UriRoute GET(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
GET
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodpublic UriRoute POST(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
POST
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodpublic UriRoute PUT(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
PUT
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodpublic UriRoute PATCH(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
PATCH
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodpublic UriRoute DELETE(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
DELETE
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodpublic UriRoute OPTIONS(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
OPTIONS
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodpublic UriRoute HEAD(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
HEAD
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodpublic UriRoute TRACE(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
RouteBuilder
Route the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
TRACE
in interface RouteBuilder
uri
- The URIbeanDefinition
- The bean definitionmethod
- The methodprotected UriRoute buildRoute(HttpMethod httpMethod, String uri, Class<?> type, String method, Class... parameterTypes)
httpMethod
- The HTTP methoduri
- The URItype
- The typemethod
- The methodparameterTypes
- ParametersUriRoute
protected UriRoute buildRoute(HttpMethod httpMethod, String uri, MethodExecutionHandle<?,Object> executableHandle)
httpMethod
- The HTTP methoduri
- The URIexecutableHandle
- The executable handleUriRoute
protected UriRoute buildBeanRoute(String httpMethodName, HttpMethod httpMethod, String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?,?> method)
httpMethodName
- The name of method. For standard http methods matches Enum.name()
httpMethod
- The http method. Is HttpMethod.CUSTOM
for non standard http methods.uri
- The uri.beanDefinition
- The definition of the bean.method
- The method description