gpt4 book ai didi

com.jetdrone.vertx.yoke.middleware.YokeRequest.body()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 12:02:40 26 4
gpt4 key购买 nike

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

YokeRequest.body介绍

[英]The request body and eventually a parsed version of it in json or map
[中]请求主体,最终是json或map中的解析版本

代码示例

代码示例来源:origin: pmlopes/yoke

@Override
  public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
    if (!com.jetdrone.vertx.yoke.json.JsonSchema.conformsSchema(request.body(), schema)) {
      next.handle(new YokeException(400, "'" + request.body() + "' does not conforms to schema"));
      return;
    }
    // the request can be handled, it does respect the content negotiation
    next.handle(null);
  }
};

代码示例来源:origin: pmlopes/yoke

@Override
  public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
    JsonObject item = request.body();
    if (item == null) {
      next.handle("Body must be JSON");
      return;
    }
    store.create(idName, item, new AsyncResultHandler<String>() {
      @Override
      public void handle(AsyncResult<String> event) {
        if (event.failed()) {
          next.handle(event.cause());
          return;
        }
        request.response().putHeader("location", request.normalizedPath() + "/" + event.result());
        request.response().setStatusCode(201);
        request.response().end();
      }
    });
  }
};

代码示例来源:origin: pmlopes/yoke

@Override
  public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
    JsonObject item = request.body();
    if (item == null) {
      next.handle("Body must be JSON");
      return;
    }
    // get the real id from the params multimap
    String id = request.params().get(idName);
    store.update(idName, id, item, new AsyncResultHandler<Number>() {
      @Override
      public void handle(AsyncResult<Number> event) {
        if (event.failed()) {
          next.handle(event.cause());
          return;
        }
        if (event.result().intValue() == 0) {
          // nothing was updated
          next.handle(404);
        } else {
          request.response().setStatusCode(204);
          request.response().end();
        }
      }
    });
  }
};

代码示例来源:origin: pmlopes/yoke

final JsonObject item = request.body();

代码示例来源:origin: pmlopes/yoke

final JsonObject item = request.body();

代码示例来源:origin: pmlopes/yoke

Object obj = request.body();
if (!(obj instanceof JsonObject)) {
  throw new YokeException(400, "Body is not JSON");

代码示例来源:origin: pmlopes/yoke

final JsonObject json = request.body();
if (json != null) {
  String method = json.getString(key);

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com