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

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

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

RestDefinition.to介绍

暂无

代码示例

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

@Override
  public void configure() throws Exception {
    // see the application.properties file for setup of the rest configuration

    // rest services under the orders context-path
    rest("/orders")
      // need to specify the POJO types the binding is using (otherwise json binding defaults to Map based)
      .get("{id}").outType(Order.class)
        .to("bean:orderService?method=getOrder(${header.id})")
        // need to specify the POJO types the binding is using (otherwise json binding defaults to Map based)
      .post().type(Order.class)
        .to("bean:orderService?method=createOrder")
        // need to specify the POJO types the binding is using (otherwise json binding defaults to Map based)
      .put().type(Order.class)
        .to("bean:orderService?method=updateOrder")
      .delete("{id}")
        .to("bean:orderService?method=cancelOrder(${header.id})");
  }
}

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

@Override
  public void configure() throws Exception {

    // configure rest-dsl
    restConfiguration()
      // to use spark-rest component and run on port 8080
      .component("spark-rest").port(8080);

    // rest services under the orders context-path
    rest("/orders")
      .get("{id}")
        .to("bean:orderService?method=getOrder(${header.id})")
      .post()
        .to("bean:orderService?method=createOrder")
      .put()
        .to("bean:orderService?method=updateOrder")
      .delete("{id}")
        .to("bean:orderService?method=cancelOrder(${header.id})");
  }
}

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

@Override
  public void configure() throws Exception {
    // configure rest-dsl
    restConfiguration()
      // to use jetty component and run on port 8080
      .component("jetty").port(8080)
      // use a smaller thread pool in jetty as we do not have so high demand yet
      .componentProperty("minThreads", "1")
      .componentProperty("maxThreads", "16")
      // to setup jetty to use the security handler
      .endpointProperty("handlers", "#securityHandler");

    // rest services under the orders context-path
    rest("/orders")
      .get("{id}")
        .to("bean:orderService?method=getOrder(${header.id})")
      .post()
        .to("bean:orderService?method=createOrder")
      .put()
        .to("bean:orderService?method=updateOrder")
      .delete("{id}")
        .to("bean:orderService?method=cancelOrder(${header.id})");
  }
}

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

@Override
  public void configure() throws Exception {
    // configure rest-dsl
    restConfiguration()
      // to use jetty component and run on port 8080
      .component("jetty").port(8080)
      // use a smaller thread pool in jetty as we do not have so high demand yet
      .componentProperty("minThreads", "1")
      .componentProperty("maxThreads", "16")
      // to setup jetty to use the security handler
      .endpointProperty("handlers", "#securityHandler");

    // rest services under the orders context-path
    rest("/orders")
      .get("{id}")
        .to("bean:orderService?method=getOrder(${header.id})")
      .post()
        .to("bean:orderService?method=createOrder")
      .put()
        .to("bean:orderService?method=updateOrder")
      .delete("{id}")
        .to("bean:orderService?method=cancelOrder(${header.id})");
  }
}

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

@Override
  public void configure() throws Exception {

    // configure rest-dsl
    restConfiguration()
      // to use spark-rest component and run on port 8080
      .component("spark-rest").port(8080)
      // and enable json binding mode
      .bindingMode(RestBindingMode.json)
      // lets enable pretty printing json responses
      .dataFormatProperty("prettyPrint", "true");

    // rest services under the orders context-path
    rest("/orders")
      // need to specify the POJO types the binding is using (otherwise json binding defaults to Map based)
      .get("{id}").outType(Order.class)
        .to("bean:orderService?method=getOrder(${header.id})")
        // need to specify the POJO types the binding is using (otherwise json binding defaults to Map based)
      .post().type(Order.class)
        .to("bean:orderService?method=createOrder")
        // need to specify the POJO types the binding is using (otherwise json binding defaults to Map based)
      .put().type(Order.class)
        .to("bean:orderService?method=updateOrder")
      .delete("{id}")
        .to("bean:orderService?method=cancelOrder(${header.id})");
  }
}

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

@Override
  public void configure() throws Exception {

    restConfiguration()
      // turn on json binding in rest-dsl
      .bindingMode(RestBindingMode.json);

    // define the rest service
    rest("/ratings/{ids}").produces("application/json")
      .get().to("bean:ratingService");
  }
}

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

@Override
  public void configure() throws Exception {

    restConfiguration()
      // turn on json binding in rest-dsl
      .bindingMode(RestBindingMode.json);

    // define the rest service
    rest("/ratings/{ids}").produces("application/json")
      .get().to("bean:ratingService");
  }
}

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

@Override
  public void configure() throws Exception {
    // define a Camel REST service using the rest-dsl
    // where we define a GET /hello as a service that routes to the hello route
    // we will cover rest-dsl in chapter 10

    rest("/").produces("text/plain")
      .get("hello")
      .to("direct:hello");

    from("direct:hello")
      .to("geocoder:address:current")
      .transform().simple("Hello from Spring Boot and Camel. We are at: ${body}");
  }
}

代码示例来源: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: 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: camelinaction/camelinaction2

.to("bean:orderService?method=getOrder(${header.id})")
  .to("bean:orderService?method=createOrder")
  .to("bean:orderService?method=updateOrder")
.delete("{id}")
  .to("bean:orderService?method=cancelOrder(${header.id})");

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

@Override
  public void configure() throws Exception {
    // configure rest to use netty4-http component as the HTTP server component
    // enable json binding mode so we can leverage camel-jackson to bind json to/from pojos
    restConfiguration().component("netty4-http").bindingMode(RestBindingMode.json)
        // expose the service as localhost:8080/service
        .host("localhost").port(8080).contextPath("service");

    // include a token id header, which we insert before the consumer completes
    // (and therefore before the consumer writes the response to the caller)
    onCompletion().modeBeforeConsumer()
        .setHeader("Token").method("tokenService");

    // use rest-dsl to define the rest service to lookup orders
    rest()
      .get("/order/{id}")
        .to("bean:orderService?method=getOrder");

  }
}

代码示例来源:origin: RedHatWorkshops/dayinthelife-integration

.produces("application/json")
.get("/").description("Retrieve all locations data")
  .to("direct:getlocationAll")
.get("/{id}")
  .to("direct:getlocation")
.get("/phone/{id}")
  .to("direct:phone")
.post("/add")
  .to("direct:addlocation")

代码示例来源:origin: RedHatWorkshops/dayinthelife-integration

.get("/").description("Retrieve all locations data")
  .responseMessage().code(200).message("Data successfully returned").endResponseMessage()
  .to("direct:getalllocations")
.get("/{id}")
  .responseMessage().code(200).message("Data successfully returned").endResponseMessage()
  .to("direct:getlocation")

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

.to("direct:ping")
.responseMessage().code(404).message("Order not found").endResponseMessage()
.responseMessage().code(500).message("Server error").endResponseMessage()
.to("bean:orderService?method=getOrder(${header.id})")
.responseMessage().code(400).message("Invalid input data").endResponseMessage()
.responseMessage().code(500).message("Server error").endResponseMessage()
.to("bean:orderService?method=createOrder")
.responseMessage().code(400).message("Invalid input data").endResponseMessage()
.responseMessage().code(500).message("Server error").endResponseMessage()
.to("bean:orderService?method=updateOrder")
.responseMessage().code(404).message("Order not found").endResponseMessage()
.responseMessage().code(500).message("Server error").endResponseMessage()
.to("bean:orderService?method=cancelOrder(${header.id})");

代码示例来源:origin: RedHatWorkshops/dayinthelife-integration

.get("/contact/{id}").description("Location Contact Info")
  .responseMessage().code(200).message("Data successfully returned").endResponseMessage()
  .to("direct:getalllocationphone")

代码示例来源:origin: RedHatWorkshops/dayinthelife-integration

.post("/automate/{apiToken}/{userid}/{openshiftappurl}").description("Automatically setup your 3scale APIs")
  .responseMessage().code(200).message("Your API is secured!").endResponseMessage()
  .to("direct:threescalesetup")

相关文章