本文整理汇总了Java中io.vertx.ext.web.Route.blockingHandler方法的典型用法代码示例。如果您正苦于以下问题:Java Route.blockingHandler方法的具体用法?Java Route.blockingHandler怎么用?Java Route.blockingHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.ext.web.Route
的用法示例。
在下文中一共展示了Route.blockingHandler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkSecurity
import io.vertx.ext.web.Route; //导入方法依赖的package包/类
private static void checkSecurity(Router router, final RouteDefinition definition) {
Route route;
if (definition.pathIsRegEx()) {
route = router.routeWithRegex(definition.getMethod(), definition.getRoutePath());
} else {
route = router.route(definition.getMethod(), definition.getRoutePath());
}
route.order(definition.getOrder()); // same order as following handler
Handler<RoutingContext> securityHandler = getSecurityHandler(definition);
if (definition.isBlocking()) {
route.blockingHandler(securityHandler);
} else {
route.handler(securityHandler);
}
}
示例2: setHandler
import io.vertx.ext.web.Route; //导入方法依赖的package包/类
/**
* Sets the handler.
*
* @param router the router
* @param data the data
*/
protected void setHandler(Router router, HandlerData data) {
// Create auth handler if is setted
if (data.authHandler() != null) {
Route authRoute = createRoute(router, data);
authRoute.handler(data.authHandler());
}
// Create route handler
Route hdRegRoute = createRoute(router, data);
Route route = createRoute(router, data);
hdRegRoute.order(Integer.MIN_VALUE).handler(ctx -> {
ctx.put(HANDLER_DATA, data);
ctx.next();
});
if (HandlerType.HANDLER.equals(data.handlerType())) {
route.handler(prepareHandler(data));
} else if (HandlerType.FAILURE_HANDLER.equals(data.handlerType())) {
route.failureHandler(prepareHandler(data));
} else if (HandlerType.BLOCKING_HANDLER.equals(data.handlerType())) {
route.blockingHandler(prepareHandler(data), false);
} else if (HandlerType.SOCKETJS_HANDLER.equals(data.handlerType())) {
route.handler(prepareSockJsHandler(data));
}
}
示例3: setHandler
import io.vertx.ext.web.Route; //导入方法依赖的package包/类
/**
* Sets the handler.
*
* @param data the data
* @param route the route
*/
protected static void setHandler(HandlerData data, Route route) {
if (HandlerType.HANDLER.equals(data.handlerType())) {
route.handler(prepareHandler(data));
} else if (HandlerType.FAILURE_HANDLER.equals(data.handlerType())) {
route.failureHandler(prepareHandler(data));
} else if (HandlerType.BLOCKING_HANDLER.equals(data.handlerType())) {
route.blockingHandler(prepareHandler(data), false);
}
}
示例4: defineInitialisationRoute
import io.vertx.ext.web.Route; //导入方法依赖的package包/类
private void defineInitialisationRoute() {
Route route = router.route(HttpMethod.GET, "/_init").produces(APPLICATION_JSON);
route.blockingHandler(routingContext -> {
logInfo("Initialising Java SDK modules... (" + new Date().toString() + ")");
sdk = APIMappingGenerator.getSDK();
logDebug(JsonObject.mapFrom(sdk).encodePrettily());
JsonObject emptyResponse = new JsonObject();
setResponse(routingContext).end(emptyResponse.encode());
});
}
示例5: defineModuleMethodTestRoute
import io.vertx.ext.web.Route; //导入方法依赖的package包/类
@SuppressWarnings("boxing")
private void defineModuleMethodTestRoute() {
Route route = router.route(HttpMethod.GET, "/:" + PARAM_MODULE + "/:" + PARAM_METHOD + "*")
.produces(APPLICATION_JSON);
route.blockingHandler(routingContext -> {
if (sdk == null) {
sendError(setResponse(routingContext), null, "Modules have not been initialised");
return;
}
HttpServerRequest request = routingContext.request();
String module = request.getParam(PARAM_MODULE);
String method = request.getParam(PARAM_METHOD);
Map<String, Object> params = retrieveQueryParameters(request);
logInfo("TEST http://localhost:" + String.valueOf(port) + request.uri() + " AT " + new Date().toString());
APICaller caller = new APICaller(sdk, config);
APIMethodResult result = null;
try {
logInfo("CALLING " + String.valueOf(method) + " ON " + String.valueOf(module) + " USING "
+ String.valueOf(toString(params)));
result = caller.callAPI(ApiUtils.convertSnakeToCamel(module, true),
ApiUtils.convertSnakeToCamel(method, false), params);
if (!result.wasExceptionRaised()) {
String resultJson = Serializer.convertResultToJson(result.getResult());
logDebug("RESULT " + String.valueOf(resultJson));
setResponse(routingContext).end(resultJson);
} else {
logDebug("RESULT error happened: " + result.getMetadata());
if (result.getMetadata() == null) {
sendError(setResponse(routingContext), null,
(result.getException().getMessage() == null)
? "Exception of type " + result.getException() + " was raised"
: result.getException().getMessage());
} else {
sendError(setResponse(routingContext), result.getMetadata().getStatusCode(),
"An error occurred during call. Call metadata: " + result.getMetadata().toString());
}
}
} catch (UnknownAPIException | APICallException e) {
sendError(setResponse(routingContext), null,
(e.getMessage() == null) ? "Exception of type " + e + " was raised" : e.getMessage());
}
});
}