Class DefaultRouteBuilder
- All Implemented Interfaces:
RouteBuilder
- Direct Known Subclasses:
AnnotatedFilterRouteBuilder,AnnotatedFunctionRouteBuilder,AnnotatedMethodRouteBuilder,DeleteEndpointRouteBuilder,ReadEndpointRouteBuilder,ServerFilterRouteBuilder,ServerWebSocketProcessor,WriteEndpointRouteBuilder
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.micronaut.web.router.RouteBuilder
RouteBuilder.UriNamingStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RouteBuilder.UriNamingStrategyARouteBuilder.UriNamingStrategywhereby camel case conventions are used.protected final ConversionServiceprotected final Charsetprotected final ExecutionHandleLocatorprotected static final org.slf4j.Loggerprotected final RouteBuilder.UriNamingStrategyFields inherited from interface io.micronaut.web.router.RouteBuilder
ID -
Constructor Summary
ConstructorsConstructorDescriptionDefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator) DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator, RouteBuilder.UriNamingStrategy uriNamingStrategy) DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator, RouteBuilder.UriNamingStrategy uriNamingStrategy, ConversionService conversionService) -
Method Summary
Modifier and TypeMethodDescriptionaddFilter(String pathPattern, BeanLocator beanLocator, BeanDefinition<? extends HttpFilter> definition) Add a filter.protected UriRoutebuildBeanRoute(String httpMethodName, HttpMethod httpMethod, String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?, ?> method) A special case that is required for non-standard http methods.protected UriRoutebuildRoute(HttpMethod httpMethod, String uri, MethodExecutionHandle<Object, Object> executableHandle) Build a route.protected UriRoutebuildRoute(HttpMethod httpMethod, String uri, Class<?> type, String method, Class<?>... parameterTypes) Build a route.protected UriRoutebuildRoute(HttpMethod httpMethod, String uri, List<MediaType> mediaTypes, MethodExecutionHandle<Object, Object> executableHandle) Build a route.DELETE(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?, ?> method) Route the specified URI template to the specified target.Route the specified URI template to the specified target.Route the specified URI template to the specified target.error(Class<?> originatingClass, Class<? extends Throwable> error, Class<?> type, String method, Class<?>[] parameterTypes) Register a route to handle the error.Register a route to handle the error.GET(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?, ?> method) Route the specified URI template to the specified target.Route the specified URI template to the specified target.Route the specified URI template to the specified target.HEAD(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?, ?> method) Route the specified URI template to the specified target.Route the specified URI template to the specified target.Route the specified URI template to the specified target.OPTIONS(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?, ?> method) Route the specified URI template to the specified target.Route the specified URI template to the specified target.Route the specified URI template to the specified target.PATCH(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?, ?> method) Route the specified URI template to the specified target.Route the specified URI template to the specified target.Route the specified URI template to the specified target.POST(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?, ?> method) Route the specified URI template to the specified target.Route the specified URI template to the specified target.Route the specified URI template to the specified target.PUT(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?, ?> method) Route the specified URI template to the specified target.Route the specified URI template to the specified target.Route the specified URI template to the specified target.Builds the necessary mappings to treat the given class as a REST endpoint.Builds the necessary mappings to treat the given class as a singular REST endpoint.status(HttpStatus status, Class<?> type, String method, Class<?>[] parameterTypes) Register a route to handle the returned status code.status(Class<?> originatingClass, HttpStatus status, Class<?> type, String method, Class<?>[] parameterTypes) Register a route to handle the returned status code.TRACE(String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?, ?> method) Route the specified URI template to the specified target.Route the specified URI template to the specified target.Route the specified URI template to the specified target.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.web.router.RouteBuilder
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
-
Field Details
-
CAMEL_CASE_NAMING_STRATEGY
ARouteBuilder.UriNamingStrategywhereby camel case conventions are used. -
LOG
protected static final org.slf4j.Logger LOG -
executionHandleLocator
-
uriNamingStrategy
-
conversionService
-
defaultCharset
-
-
Constructor Details
-
DefaultRouteBuilder
- Parameters:
executionHandleLocator- The execution handler locator
-
DefaultRouteBuilder
public DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator, RouteBuilder.UriNamingStrategy uriNamingStrategy) - Parameters:
executionHandleLocator- The execution handler locatoruriNamingStrategy- The URI naming strategy
-
DefaultRouteBuilder
public DefaultRouteBuilder(ExecutionHandleLocator executionHandleLocator, RouteBuilder.UriNamingStrategy uriNamingStrategy, ConversionService conversionService) - Parameters:
executionHandleLocator- The execution handler locatoruriNamingStrategy- The URI naming strategyconversionService- The conversion service
-
-
Method Details
-
getExposedPorts
- Specified by:
getExposedPortsin interfaceRouteBuilder- Returns:
- The exposed ports
-
getFilterRoutes
- Specified by:
getFilterRoutesin interfaceRouteBuilder- Returns:
- The filter routes
-
addFilter
public FilterRoute addFilter(String pathPattern, BeanLocator beanLocator, BeanDefinition<? extends HttpFilter> definition) Description copied from interface:RouteBuilderAdd a filter.- Specified by:
addFilterin interfaceRouteBuilder- Parameters:
pathPattern- The path pattern for the filterbeanLocator- The bean locatordefinition- The bean definition- Returns:
- The
FilterRoute
-
getStatusRoutes
- Specified by:
getStatusRoutesin interfaceRouteBuilder- Returns:
- Obtain a list of constructed routes
-
getErrorRoutes
- Specified by:
getErrorRoutesin interfaceRouteBuilder- Returns:
- Obtain a list of constructed routes
-
getUriRoutes
- Specified by:
getUriRoutesin interfaceRouteBuilder- Returns:
- Obtain a list of constructed routes
-
getUriNamingStrategy
- Specified by:
getUriNamingStrategyin interfaceRouteBuilder- Returns:
- The URI naming strategy
-
resources
Description copied from interface:RouteBuilderBuilds 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.- Specified by:
resourcesin interfaceRouteBuilder- Parameters:
cls- The class- Returns:
- The
ResourceRoute
-
single
Description copied from interface:RouteBuilderBuilds 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.- Specified by:
singlein interfaceRouteBuilder- Parameters:
cls- The class- Returns:
- The
ResourceRoute
-
status
public StatusRoute status(Class<?> originatingClass, HttpStatus status, Class<?> type, String method, Class<?>[] parameterTypes) Description copied from interface:RouteBuilderRegister a route to handle the returned status code. This implementation considers the originatingClass for matching.- Specified by:
statusin interfaceRouteBuilder- Parameters:
originatingClass- The class where the error originates fromstatus- The status codetype- The typemethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
status
public StatusRoute status(HttpStatus status, Class<?> type, String method, Class<?>[] parameterTypes) Description copied from interface:RouteBuilderRegister a route to handle the returned status code.- Specified by:
statusin interfaceRouteBuilder- Parameters:
status- The status codetype- The typemethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
error
public ErrorRoute error(Class<?> originatingClass, Class<? extends Throwable> error, Class<?> type, String method, Class<?>[] parameterTypes) Description copied from interface:RouteBuilderRegister a route to handle the error.- Specified by:
errorin interfaceRouteBuilder- Parameters:
originatingClass- The class where the error originates fromerror- The error typetype- The type to route tomethod- The method to route toparameterTypes- The parameter types for the target method- Returns:
- The route
-
error
public ErrorRoute error(Class<? extends Throwable> error, Class<?> type, String method, Class<?>[] parameterTypes) Description copied from interface:RouteBuilderRegister a route to handle the error.- Specified by:
errorin interfaceRouteBuilder- Parameters:
error- The errortype- The typemethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
GET
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
GETin interfaceRouteBuilder- Parameters:
uri- The URItarget- The targetmethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
GET
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
GETin interfaceRouteBuilder- Parameters:
uri- The URItype- The typemethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
POST
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
POSTin interfaceRouteBuilder- Parameters:
uri- The URItarget- The targetmethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
POST
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
POSTin interfaceRouteBuilder- Parameters:
uri- The URItype- The typemethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
PUT
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
PUTin interfaceRouteBuilder- Parameters:
uri- The URItarget- The targetmethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
PUT
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
PUTin interfaceRouteBuilder- Parameters:
uri- The URItype- The typemethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
PATCH
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
PATCHin interfaceRouteBuilder- Parameters:
uri- The URItarget- The targetmethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
PATCH
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
PATCHin interfaceRouteBuilder- Parameters:
uri- The URItype- The typemethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
DELETE
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
DELETEin interfaceRouteBuilder- Parameters:
uri- The URItarget- The targetmethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
DELETE
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
DELETEin interfaceRouteBuilder- Parameters:
uri- The URItype- The typemethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
OPTIONS
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
OPTIONSin interfaceRouteBuilder- Parameters:
uri- The URItarget- The targetmethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
OPTIONS
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
OPTIONSin interfaceRouteBuilder- Parameters:
uri- The URItype- The typemethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
HEAD
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
HEADin interfaceRouteBuilder- Parameters:
uri- The URItarget- The targetmethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
HEAD
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
HEADin interfaceRouteBuilder- Parameters:
uri- The URItype- The typemethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
TRACE
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
TRACEin interfaceRouteBuilder- Parameters:
uri- The URItarget- The targetmethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
TRACE
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
TRACEin interfaceRouteBuilder- Parameters:
uri- The URItype- The typemethod- The methodparameterTypes- The parameter types for the target method- Returns:
- The route
-
GET
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
GETin interfaceRouteBuilder- Parameters:
uri- The URIbeanDefinition- The bean definitionmethod- The method- Returns:
- The route
-
POST
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
POSTin interfaceRouteBuilder- Parameters:
uri- The URIbeanDefinition- The bean definitionmethod- The method- Returns:
- The route
-
PUT
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
PUTin interfaceRouteBuilder- Parameters:
uri- The URIbeanDefinition- The bean definitionmethod- The method- Returns:
- The route
-
PATCH
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
PATCHin interfaceRouteBuilder- Parameters:
uri- The URIbeanDefinition- The bean definitionmethod- The method- Returns:
- The route
-
DELETE
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
DELETEin interfaceRouteBuilder- Parameters:
uri- The URIbeanDefinition- The bean definitionmethod- The method- Returns:
- The route
-
OPTIONS
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
OPTIONSin interfaceRouteBuilder- Parameters:
uri- The URIbeanDefinition- The bean definitionmethod- The method- Returns:
- The route
-
HEAD
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
HEADin interfaceRouteBuilder- Parameters:
uri- The URIbeanDefinition- The bean definitionmethod- The method- Returns:
- The route
-
TRACE
Description copied from interface:RouteBuilderRoute the specified URI template to the specified target.
The number of variables in the template should match the number of method arguments
- Specified by:
TRACEin interfaceRouteBuilder- Parameters:
uri- The URIbeanDefinition- The bean definitionmethod- The method- Returns:
- The route
-
buildRoute
protected UriRoute buildRoute(HttpMethod httpMethod, String uri, Class<?> type, String method, Class<?>... parameterTypes) Build a route.- Parameters:
httpMethod- The HTTP methoduri- The URItype- The typemethod- The methodparameterTypes- Parameters- Returns:
- an
UriRoute
-
buildRoute
protected UriRoute buildRoute(HttpMethod httpMethod, String uri, MethodExecutionHandle<Object, Object> executableHandle) Build a route.- Parameters:
httpMethod- The HTTP methoduri- The URIexecutableHandle- The executable handle- Returns:
- an
UriRoute
-
buildRoute
protected UriRoute buildRoute(HttpMethod httpMethod, String uri, List<MediaType> mediaTypes, MethodExecutionHandle<Object, Object> executableHandle) Build a route.- Parameters:
httpMethod- The HTTP methoduri- The URImediaTypes- The media typesexecutableHandle- The executable handle- Returns:
- an
UriRoute - Since:
- 4.2.0
-
buildBeanRoute
protected UriRoute buildBeanRoute(String httpMethodName, HttpMethod httpMethod, String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?, ?> method) A special case that is required for non-standard http methods.- Parameters:
httpMethodName- The name of method. For standard http methods matchesEnum.name()httpMethod- The http method. IsHttpMethod.CUSTOMfor non-standard http methods.uri- The uri.beanDefinition- The definition of the bean.method- The method description- Returns:
- The uri route corresponding to the method.
-