new DesignDrivenRouterFactory()
Main interface for Design Driven Router factory
Methods
addFailureHandler(method, path, failureHandler) → {DesignDrivenRouterFactory}
Add a failure handler to a path with a method. If combination path/method is not available in
specification, it will throw a RouterFactoryException
Parameters:
| Name | Type | Description |
|---|---|---|
method |
Object | |
path |
string | |
failureHandler |
function |
Returns:
- Type
- DesignDrivenRouterFactory
addHandler(method, path, handler) → {DesignDrivenRouterFactory}
Add an handler to a path with a method. If combination path/method is not available in
specification, it will throw a RouterFactoryException
Parameters:
| Name | Type | Description |
|---|---|---|
method |
Object | |
path |
string | |
handler |
function |
Returns:
- Type
- DesignDrivenRouterFactory
addSecurityHandler(securitySchemaName, handler) → {DesignDrivenRouterFactory}
Mount to paths that have to follow a security schema a security handler
Parameters:
| Name | Type | Description |
|---|---|---|
securitySchemaName |
string | |
handler |
function |
Returns:
- Type
- DesignDrivenRouterFactory
enableValidationFailureHandler(enable) → {DesignDrivenRouterFactory}
Enable or disable validation failure handler. If you enable it, during router creation it will be mounted a
built-in (or custom with function DesignDrivenRouterFactory#setValidationFailureHandler)
ValidationException handler as a failure handler. If failure is different from ValidationException, it will be
called the next failure handler.
Parameters:
| Name | Type | Description |
|---|---|---|
enable |
boolean |
Returns:
- Type
- DesignDrivenRouterFactory
getRouter() → {Router}
Construct a new router based on spec. It will fail if you are trying to mount a spec with security schemes
without assigned handlers
Note: Router is constructed in this function, so it will be respected the path definition ordering.
Note: Router is constructed in this function, so it will be respected the path definition ordering.
Returns:
- Type
- Router
mountOperationsWithoutHandlers(enable) → {DesignDrivenRouterFactory}
Automatic mount handlers that return HTTP 501 status code for operations where you didn't specify an handler.
Parameters:
| Name | Type | Description |
|---|---|---|
enable |
boolean |
Returns:
- Type
- DesignDrivenRouterFactory
setValidationFailureHandler(handler) → {DesignDrivenRouterFactory}
Set default validation failure handler. You can disable this feature from
DesignDrivenRouterFactory#enableValidationFailureHandler
Parameters:
| Name | Type | Description |
|---|---|---|
handler |
function |
Returns:
- Type
- DesignDrivenRouterFactory