本文整理汇总了Java中io.vertx.ext.web.RoutingContext.put方法的典型用法代码示例。如果您正苦于以下问题:Java RoutingContext.put方法的具体用法?Java RoutingContext.put怎么用?Java RoutingContext.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.ext.web.RoutingContext
的用法示例。
在下文中一共展示了RoutingContext.put方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
@Override
public void handle(RoutingContext context) {
HttpServerRequest request = context.request();
// we need to keep state since we can be called again on reroute
Boolean handled = context.get(BODY_HANDLED);
if (handled == null || !handled) {
BHandler handler = new BHandler(context);
request.handler(handler);
request.endHandler(v -> handler.end());
context.put(BODY_HANDLED, true);
} else {
// on reroute we need to re-merge the form params if that was desired
if (mergeFormAttributes && request.isExpectMultipart()) {
request.params().addAll(request.formAttributes());
}
context.next();
}
}
示例2: handle
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
@Override
public void handle(RoutingContext rc) {
// we define a hardcoded title for our application
rc.put("name", "Vert.x Web");
getUserProfiles(rc)
.thenAccept(profiles -> rc.put("userProfiles", profiles))
.thenAccept(v -> {
// and now delegate to the engine to render it.
engine.render(rc, "templates/index.hbs", res -> {
if (res.succeeded()) {
rc.response().end(res.result());
} else {
rc.fail(res.cause());
}
});
});
}
示例3: handle
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
@Override
public void handle(RoutingContext ctx) {
String tid = ctx.request().getHeader(HttpHeaders.TID);
if (StringUtils.isEmpty(tid)) {
tid = TidGenerator.generate();
ctx.put(HttpHeaders.TID, tid);
ctx.request().headers().add(HttpHeaders.TID, tid);
ctx.request().headers().add(HttpHeaders.GATEWAY_ORIGIN, ctx.request().absoluteURI());
ctx.response().putHeader(HttpHeaders.TID, tid);
if (log.isDebugEnabled()) {
log.debug("Received request to [{}] with TID [{}]", ctx.request().uri(), tid);
}
}
final String fTid = tid;
ctx.response().bodyEndHandler(v -> {
if (log.isDebugEnabled()) {
log.debug("Finish request for TID [{}]", fTid);
}
});
ctx.next();
}
示例4: onRequest
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
private void onRequest(RoutingContext context) {
if (transport == null) {
transport = CseContext.getInstance().getTransportManager().findTransport(Const.RESTFUL);
}
HttpServletRequestEx requestEx = new VertxServerRequestToHttpServletRequest(context);
HttpServletResponseEx responseEx = new VertxServerResponseToHttpServletResponse(context.response());
RestProducerInvocation restProducerInvocation = new RestProducerInvocation();
context.put(RestConst.REST_PRODUCER_INVOCATION, restProducerInvocation);
restProducerInvocation.invoke(transport, requestEx, responseEx, httpServerFilters);
}
示例5: loginHandler
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
private void loginHandler(RoutingContext context) {
context.put("title", "Login");
templateEngine.render(context, "templates", "/login.ftl", ar -> {
if (ar.succeeded()) {
context.response().putHeader("Content-Type", "text/html");
context.response().end(ar.result());
} else {
context.fail(ar.cause());
}
});
}
示例6: handle
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
@Override
public void handle(final RoutingContext c) {
LOG.debug("Handling {} with from={} to={} protected={}", c, pathContext.getFrom(), pathContext.getTo(), pathContext.isProtected());
c.put(PATH_CONTEXT, pathContext);
c.next();
}
示例7: buildArgs
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
/**
* Template method
*
* @param context
* @param event
* @return
*/
protected Object[] buildArgs(final RoutingContext context,
final Event event) {
Object[] cached = context.get(ID.PARAMS);
if (null == cached) {
cached = this.analyzer.in(context, event);
context.put(ID.PARAMS, cached);
}
// Validation handler has been get the parameters.
return cached;
}
示例8: pushContext
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
static void pushContext(RoutingContext context, Object object) {
Assert.notNull(context, "Missing context!");
Assert.notNull(object, "Can't push null into context!");
context.put(ContextProviderFactory.getContextKey(object), object);
}