Class ProcessBasedRouter
java.lang.Object
com.kingsrook.qqq.middleware.javalin.routeproviders.ProcessBasedRouter
- All Implemented Interfaces:
QJavalinRouteProviderInterface
Route provider that executes QQQ processes in response to HTTP requests.
This provider bridges Javalin HTTP routes to QQQ's process execution engine,
allowing processes to be exposed as REST endpoints. Request data (path params,
query params, body, headers) is passed into the process via ProcessBasedRouterPayload,
and process output is used to construct the HTTP response.
Supports:
- Multiple HTTP methods (GET, POST, PUT, DELETE, etc.)
- Custom authentication via RouteAuthenticatorInterface
- Custom request/response handling via RouteProviderContextHandlerInterface
- Path parameters, query parameters, form data, and request bodies
Usage Example:
new ProcessBasedRouter("/api/orders/{orderId}", "processOrderRequest")
.withRouteAuthenticator(new QCodeReference(ApiAuthenticator.class))
.withMethods(List.of("GET", "POST"))
-
Constructor Summary
ConstructorsConstructorDescriptionProcessBasedRouter(JavalinRouteProviderMetaData routeProvider) Constructor that builds router from meta-data configuration.ProcessBasedRouter(String hostedPath, String processName) Constructor for process-based route with default GET method.ProcessBasedRouter(String hostedPath, String processName, List<String> methods) Constructor for process-based route with specified HTTP methods. -
Method Summary
Modifier and TypeMethodDescriptionGetter for contextHandlerio.javalin.apibuilder.EndpointGroupGet the Javalin endpoint group configuration for this route.Getter for routeAuthenticatorvoidsetContextHandler(QCodeReference contextHandler) Setter for contextHandlervoidsetQInstance(QInstance qInstance) Set the QInstance for this route provider.voidsetRouteAuthenticator(QCodeReference routeAuthenticator) Setter for routeAuthenticatorwithContextHandler(QCodeReference contextHandler) Fluent setter for contextHandlerwithRouteAuthenticator(QCodeReference routeAuthenticator) Fluent setter for routeAuthenticatorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.kingsrook.qqq.middleware.javalin.QJavalinRouteProviderInterface
acceptJavalinConfig, acceptJavalinService
-
Constructor Details
-
ProcessBasedRouter
-
ProcessBasedRouter
Constructor that builds router from meta-data configuration.- Parameters:
routeProvider- meta-data containing route configuration
-
ProcessBasedRouter
Constructor for process-based route with specified HTTP methods.- Parameters:
hostedPath- the URL path where this route will be hosted (e.g., "/api/orders/{id}")processName- the name of the QQQ process to execute for this routemethods- list of HTTP methods to support (GET, POST, PUT, DELETE, PATCH); defaults to GET if null
-
-
Method Details
-
setQInstance
Set the QInstance for this route provider. Called by the framework during initialization to provide access to the QQQ instance configuration.- Specified by:
setQInstancein interfaceQJavalinRouteProviderInterface- Parameters:
qInstance- the QInstance containing meta-data and configuration
-
getJavalinEndpointGroup
public io.javalin.apibuilder.EndpointGroup getJavalinEndpointGroup()Get the Javalin endpoint group configuration for this route. Creates route registrations for all configured HTTP methods, mapping them to the handleRequest method that executes the QQQ process.- Specified by:
getJavalinEndpointGroupin interfaceQJavalinRouteProviderInterface- Returns:
- EndpointGroup containing route registrations
- Throws:
IllegalArgumentException- if an unrecognized HTTP method is specified
-
getRouteAuthenticator
-
setRouteAuthenticator
Setter for routeAuthenticator- See Also:
-
withRouteAuthenticator
Fluent setter for routeAuthenticator- Parameters:
routeAuthenticator- code reference to the route authenticator implementation- Returns:
- this
-
getContextHandler
-
setContextHandler
-
withContextHandler
Fluent setter for contextHandler- Parameters:
contextHandler- code reference to the context handler implementation- Returns:
- this
-