Skip to content

Commit

Permalink
Merge pull request apache#88 from smongiar/CSB-2059
Browse files Browse the repository at this point in the history
Refactor type-converter
  • Loading branch information
Croway authored Jul 24, 2023
2 parents f4c1c24 + 130da2f commit 5b8389b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion type-converter/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ Required Camel Maven Package Plugin and build helper plugin - see pom.xml for de

=== How to run

You can run this example using
You can run example tests using

mvn test

or in alternative, try to send own data through a rest service, performing a runtime convertion

curl -X POST -H 'Content-Type: text/plain' --data-binary 'Chuck Norris 83' localhost:8080/api/convert

=== Help and contributions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ public void configure() throws Exception {
rest("/convert")
.produces("text/plain")
.post()
.to("direct:convert1")
.param().name("person").type(RestParamType.body).dataType("string").endParam();
.to("direct:convert1");


from("direct:convert1")
.process(exchange -> {
String inputString = exchange.getIn().getBody(String.class);
byte[] inputBytes = inputString.getBytes();
exchange.getOut().setBody(inputBytes);
})
.convertBodyTo(Person.class)
.log("${body}");
}
Expand Down

0 comments on commit 5b8389b

Please sign in to comment.