org.apache.camel.model.rest.RestDefinition.consumes()方法的使用及代码示例

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

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

RestDefinition.consumes介绍

暂无

代码示例

代码示例来源:origin: camelinaction/camelinaction2

@Override
public void configure() throws Exception {
  // use the restlet component on port 8080 as the REST server
  // no need for binding to json/jaxb as the rest services are using plain text
  restConfiguration().component("restlet").port(8080);
  rest("/rest").consumes("application/text").produces("application/text")
    // ping rest service
    .get("ping")
      .route().routeId("ping")
      .transform(constant("PONG\n"))
    .endRest()
    // controlbus to start/stop the route
    .get("route/{action}")
      // use dynamic-to so the action is provided from the url
      .toD("controlbus:route?routeId=ping&action=${header.action}");
}

代码示例来源:origin: camelinaction/camelinaction2

@Override
  public void configure() throws Exception {

    // use jetty for rest service
    restConfiguration("jetty").port("{{port}}").contextPath("api")
        // turn on json binding
        .bindingMode(RestBindingMode.json)
        // turn off binding error on empty beans
        .dataFormatProperty("disableFeatures", "FAIL_ON_EMPTY_BEANS")
        // enable swagger api documentation
        .apiContextPath("api-doc")
        .enableCORS(true);

    // define the rest service
    rest("/cart").consumes("application/json").produces("application/json")
      // get returns List<CartDto>
      .get().outTypeList(CartDto.class).description("Returns the items currently in the shopping cart")
        .to("bean:cart?method=getItems")
      // get accepts CartDto
      .post().type(CartDto.class).description("Adds the item to the shopping cart")
        .to("bean:cart?method=addItem")
      .delete().description("Removes the item from the shopping cart")
        .param().name("itemId").description("Id of item to remove").endParam()
        .to("bean:cart?method=removeItem");
  }
}

代码示例来源:origin: org.openksavi.sponge/sponge-rest-api

protected void createRestDefinition() {
    .consumes(RestApiConstants.APPLICATION_JSON_VALUE).produces(RestApiConstants.APPLICATION_JSON_VALUE)
    .post("/version").description("Get the Sponge version").type(RestGetVersionRequest.class).outType(RestGetVersionResponse.class)
      .param().name("body").type(body).description("Get Sponge version request").endParam()

代码示例来源:origin: camelinaction/camelinaction2

@Override
  public void configure() throws Exception {

    // use jetty for rest service
    restConfiguration("jetty").port("{{port}}").contextPath("api")
        // turn on json binding
        .bindingMode(RestBindingMode.json)
        // turn off binding error on empty beans
        .dataFormatProperty("disableFeatures", "FAIL_ON_EMPTY_BEANS")
        // enable swagger api documentation
        .apiContextPath("api-doc")
        .enableCORS(true);

    // define the rest service
    rest("/cart").consumes("application/json").produces("application/json")
      // get returns List<CartDto>
      .get().outType(CartDto[].class).description("Returns the items currently in the shopping cart")
        .to("bean:cart?method=getItems")
      // get accepts CartDto
      .post().type(CartDto.class).description("Adds the item to the shopping cart")
        .to("bean:cart?method=addItem")
      .delete().description("Removes the item from the shopping cart")
        .param().name("itemId").description("Id of item to remove").endParam()
        .to("bean:cart?method=removeItem");
  }
}

代码示例来源:origin: redhat-developer-demos/istio-tutorial

@Override
public void configure() throws Exception {
  restConfiguration()
      .component("servlet")
      .enableCORS(true)
      .contextPath("/")
      .bindingMode(RestBindingMode.auto);
  rest("/").get().consumes(MediaType.TEXT_PLAIN_VALUE)
      .route().routeId("root")
      .pipeline()
        .bean("CustomerCamelRoute", "addTracer")
        .to("http4:preference:8080/?httpClient.connectTimeout=1000&bridgeEndpoint=true&copyHeaders=true&connectionClose=true")
      .end()
      .convertBodyTo(String.class)
      .onException(HttpOperationFailedException.class)
        .handled(true)
        .process(this::handleHttpFailure)
        .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(503))
      .end()
      .onException(Exception.class)
        .log(exceptionMessage().toString())
        .handled(true)
        .transform(simpleF(RESPONSE_STRING_FORMAT, exceptionMessage()))
        .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(503))
      .end()
      .transform(simpleF(RESPONSE_STRING_FORMAT, "${body}"))
  .endRest();
}

相关文章