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

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

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

Request.method介绍

暂无

代码示例

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

@Override
public String getRequestMethod() {
 return req.method();
}

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

@Override public String getRequestMethod() {
 return req.method();
}

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

@Override
public String method() {
 return req.method();
}

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

/**
 * Creates a new {@link CsrfHandler} handler and use the given name to save the token in the
 * {@link Session} and or extract the token from incoming requests.
 *
 * @param name Token's name.
 */
public CsrfHandler(final String name) {
 this.name = requireNonNull(name, "Name is required.");
 tokenGen(req -> UUID.randomUUID().toString());
 requireTokenOn(req -> REQUIRE_ON.contains(req.method()));
}

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

@Override
public void handle(final Request req, final Response rsp) throws Exception {
 if (!rsp.header(ALLOW).isSet()) {
  Set<String> allow = new LinkedHashSet<>();
  Set<String> methods = new LinkedHashSet<>(Route.METHODS);
  String path = req.path();
  methods.remove(req.method());
  for (String method : methods) {
   routes.stream()
     .filter(route -> route.matches(method, path, MediaType.all, MediaType.ALL).isPresent())
     .forEach(route -> allow.add(route.method()));
  }
  rsp.header(ALLOW, Joiner.on(SEP).join(allow))
    .length(0)
    .status(Status.OK);
 }
}

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

sb.append(BL).append(df.apply(timestamp)).append(BR);
sb.append(SP);
sb.append(Q).append(req.method());
sb.append(SP);
sb.append(req.path());

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

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: jooby-project/jooby

private void preflight(final Cors cors, final Request req, final Response rsp,
  final String origin) {
 /**
  * Allowed method
  */
 boolean allowMethod = req.header(AC_REQUEST_METHOD).toOptional()
   .map(cors::allowMethod)
   .orElse(false);
 if (!allowMethod) {
  return;
 }
 /**
  * Allowed headers
  */
 List<String> headers = req.header(AC_REQUEST_HEADERS).toOptional().map(header ->
   Splitter.on(',').trimResults().omitEmptyStrings().splitToList(header)
   ).orElse(Collections.emptyList());
 if (!cors.allowHeaders(headers)) {
  return;
 }
 /**
  * Allowed methods
  */
 rsp.header(AC_ALLOW_METHODS, join(cors.allowedMethods()));
 List<String> allowedHeaders = cors.anyHeader() ? headers : cors.allowedHeaders();
 rsp.header(AC_ALLOW_HEADERS, join(allowedHeaders));

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

@Override
public String method() {
 return req.method();
}

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

@Override
public String getRequestMethod() {
 return req.method();
}

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

/**
 * Creates a new {@link CsrfHandler} handler and use the given name to save the token in the
 * {@link Session} and or extract the token from incoming requests.
 *
 * @param name Token's name.
 */
public CsrfHandler(final String name) {
 this.name = requireNonNull(name, "Name is required.");
 tokenGen(req -> UUID.randomUUID().toString());
 requireTokenOn(req -> REQUIRE_ON.contains(req.method()));
}

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

@Override
public void handle(final Request req, final Response rsp) throws Exception {
 if (!rsp.header(ALLOW).isSet()) {
  Set<String> allow = new LinkedHashSet<>();
  Set<String> methods = new LinkedHashSet<>(Route.METHODS);
  String path = req.path();
  methods.remove(req.method());
  for (String method : methods) {
   routes.stream()
     .filter(route -> route.matches(method, path, MediaType.all, MediaType.ALL).isPresent())
     .forEach(route -> allow.add(route.method()));
  }
  rsp.header(ALLOW, Joiner.on(SEP).join(allow))
    .length(0)
    .status(Status.OK);
 }
}

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

sb.append(BL).append(df.apply(timestamp)).append(BR);
sb.append(SP);
sb.append(Q).append(req.method());
sb.append(SP);
sb.append(req.path());

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

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)));
}

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

private void preflight(final Cors cors, final Request req, final Response rsp,
  final String origin) {
 /**
  * Allowed method
  */
 boolean allowMethod = req.header(AC_REQUEST_METHOD).toOptional()
   .map(cors::allowMethod)
   .orElse(false);
 if (!allowMethod) {
  return;
 }
 /**
  * Allowed headers
  */
 List<String> headers = req.header(AC_REQUEST_HEADERS).toOptional().map(header ->
   Splitter.on(',').trimResults().omitEmptyStrings().splitToList(header)
   ).orElse(Collections.emptyList());
 if (!cors.allowHeaders(headers)) {
  return;
 }
 /**
  * Allowed methods
  */
 rsp.header(AC_ALLOW_METHODS, join(cors.allowedMethods()));
 List<String> allowedHeaders = cors.anyHeader() ? headers : cors.allowedHeaders();
 rsp.header(AC_ALLOW_HEADERS, join(allowedHeaders));

相关文章