org.jooby.Request.route()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(460)

本文整理了Java中org.jooby.Request.route方法的一些代码示例,展示了Request.route的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.route方法的具体详情如下:
包路径:org.jooby.Request
类名称:Request
方法名:route

Request.route介绍

暂无

代码示例

代码示例来源:origin: jooby-project/jooby

@Override
public Route route() {
 return req.route();
}

代码示例来源:origin: jooby-project/jooby

private static Object[] vars(final Request req) {
 Map<Object, String> vars = req.route().vars();
 return vars.values().toArray(new Object[vars.size()]);
}

代码示例来源:origin: jooby-project/jooby

/**
 * @return HTTP method.
 */
@Nonnull
default String method() {
 return route().method();
}

代码示例来源:origin: jooby-project/jooby

/**
 * Escape the path using {@link UrlEscapers#urlFragmentEscaper()}.
 *
 * Given:
 *
 * <pre>{@code
 *  http://domain.com/404<h1>X</h1> {@literal ->} /404%3Ch1%3EX%3C/h1%3E
 * }</pre>
 *
 * @param escape True if we want to escape this path.
 * @return The request URL pathname.
 */
@Nonnull
default String path(final boolean escape) {
 String path = route().path();
 return escape ? UrlEscapers.urlFragmentEscaper().escape(path) : path;
}

代码示例来源:origin: jooby-project/jooby

protected void handshake(final Request req, final Runnable handler) throws Exception {
 this.injector = req.require(Injector.class);
 this.renderers = ImmutableList.copyOf(injector.getInstance(Renderer.KEY));
 this.produces = req.route().produces();
 this.locals = req.attributes();
 this.lastEventId = req.header("Last-Event-ID");
 this.locale = req.locale();
 handshake(handler);
}

代码示例来源:origin: jooby-project/jooby

@Override public void handle(Request req, Response rsp) {
  TimedSupport timed = TimedSupport.create(req.route());
  if (timed != null) {
   MeterRegistry registry = req.require(MeterRegistry.class);
   TimedSupport.Sample sample = timed.start(registry);
   rsp.complete((request, response, cause) -> sample.stop());
  }
 }
}

代码示例来源:origin: jooby-project/jooby

Route route = req.route();
 ImmutableMap.Builder<String, Object> map = ImmutableMap.builder();
 return map
  req.method(), req.path(), req.route().print(6), err);
rsp.type(MediaType.html).send(writer.toString());

代码示例来源:origin: jooby-project/jooby

@Override
public void handle(final Request req, final Response rsp, final Err ex) throws Throwable {
 log.error("execution of: {}{} resulted in exception\nRoute:\n{}\n\nStacktrace:",
   req.method(), req.path(), req.route().print(6), ex);
 Config conf = req.require(Config.class);
 boolean stackstrace = Try.apply(() -> conf.getBoolean("err.stacktrace"))
   .orElse(req.require(Env.class).name().equals("dev"));
 rsp.send(
   Results
     .when(MediaType.html, () -> Results.html(VIEW).put("err", ex.toMap(stackstrace)))
     .when(MediaType.all, () -> ex.toMap(stackstrace)));
}

代码示例来源:origin: org.jooby/jooby

@Override
public Route route() {
 return req.route();
}

代码示例来源:origin: org.jooby/jooby

/**
 * @return HTTP method.
 */
@Nonnull
default String method() {
 return route().method();
}

代码示例来源:origin: org.jooby/jooby

private static Object[] vars(final Request req) {
 Map<Object, String> vars = req.route().vars();
 return vars.values().toArray(new Object[vars.size()]);
}

代码示例来源:origin: org.jooby/jooby

/**
 * Escape the path using {@link UrlEscapers#urlFragmentEscaper()}.
 *
 * Given:
 *
 * <pre>{@code
 *  http://domain.com/404<h1>X</h1> {@literal ->} /404%3Ch1%3EX%3C/h1%3E
 * }</pre>
 *
 * @param escape True if we want to escape this path.
 * @return The request URL pathname.
 */
@Nonnull
default String path(final boolean escape) {
 String path = route().path();
 return escape ? UrlEscapers.urlFragmentEscaper().escape(path) : path;
}

代码示例来源:origin: org.jooby/jooby

protected void handshake(final Request req, final Runnable handler) throws Exception {
 this.injector = req.require(Injector.class);
 this.renderers = ImmutableList.copyOf(injector.getInstance(Renderer.KEY));
 this.produces = req.route().produces();
 this.locals = req.attributes();
 this.lastEventId = req.header("Last-Event-ID");
 this.locale = req.locale();
 handshake(handler);
}

代码示例来源:origin: org.jooby/jooby-whoops

Route route = req.route();
 ImmutableMap.Builder<String, Object> map = ImmutableMap.builder();
 return map
  req.method(), req.path(), req.route().print(6), err);
rsp.type(MediaType.html).send(writer.toString());

代码示例来源:origin: org.jooby/jooby

@Override
public void handle(final Request req, final Response rsp, final Err ex) throws Throwable {
 log.error("execution of: {}{} resulted in exception\nRoute:\n{}\n\nStacktrace:",
   req.method(), req.path(), req.route().print(6), ex);
 Config conf = req.require(Config.class);
 boolean stackstrace = Try.apply(() -> conf.getBoolean("err.stacktrace"))
   .orElse(req.require(Env.class).name().equals("dev"));
 rsp.send(
   Results
     .when(MediaType.html, () -> Results.html(VIEW).put("err", ex.toMap(stackstrace)))
     .when(MediaType.all, () -> ex.toMap(stackstrace)));
}

相关文章