Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

Commit

Permalink
uniform constructor names
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwawi committed Apr 5, 2016
1 parent e930298 commit 1a99d4b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
11 changes: 8 additions & 3 deletions apollo-entity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MyApplication {

static void init(Environment environment) {
MyApplication app = new MyApplication();
EntityMiddleware entity = EntityMiddleware.jackson(OBJECT_MAPPER);
EntityMiddleware entity = EntityMiddleware.forJackson(OBJECT_MAPPER);

Route<SyncHandler<Response<ByteString>>> route = Route.with(
entity.direct(Person.class),
Expand All @@ -71,6 +71,10 @@ class MyApplication {
}
```

[`EntityMiddleware`][1] also support custom codecs through the `forCodec(EntityCodec)` static
constructor. An [`EntityCodec`][2] defines how to read and write entity types from the `ByteString`
payloads that apollo handle natively.

## Handler signatures

The [`EntityMiddleware`][1] interface can create middlewares for several types of handler
Expand Down Expand Up @@ -127,8 +131,9 @@ rc -> this::handler

---

See [`EntityTest`][2] for a complete list of route options and tests.
See [`EntityMiddlewareTest`][3] for a complete list of route options and tests.

[1]: src/main/java/com/spotify/apollo/entity/EntityMiddleware.java
[2]: src/test/java/com/spotify/apollo/entity/EntityTest.java
[2]: src/main/java/com/spotify/apollo/entity/EntityCodec.java
[3]: src/test/java/com/spotify/apollo/entity/EntityMiddlewareTest.java
[project skeleton]: https://github.com/spotify/apollo/tree/master/apollo-http-service#maven
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ static EntityMiddleware forCodec(EntityCodec codec, String contentType) {
return new CodecEntityMiddleware(codec, contentType);
}

static EntityMiddleware jackson(ObjectMapper objectMapper) {
static EntityMiddleware forJackson(ObjectMapper objectMapper) {
return new CodecEntityMiddleware(new JacksonEntityCodec(objectMapper));
}

static EntityMiddleware jackson(ObjectMapper objectMapper, String contentType) {
static EntityMiddleware forJackson(ObjectMapper objectMapper, String contentType) {
return new CodecEntityMiddleware(new JacksonEntityCodec(objectMapper), contentType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class EntityCodecsTest {

@Test
public void testWithCustomJacksonMapper() throws Exception {
EntityMiddleware e = EntityMiddleware.jackson(OBJECT_MAPPER);
EntityMiddleware e = EntityMiddleware.forJackson(OBJECT_MAPPER);

ServiceHelper service = ServiceHelper.create(entityApp(e), "entity-test");
service.start();
Expand All @@ -75,7 +75,7 @@ public void testWithCustomJacksonMapper() throws Exception {

@Test
public void testWithCustomContentType() throws Exception {
EntityMiddleware e = EntityMiddleware.jackson(
EntityMiddleware e = EntityMiddleware.forJackson(
OBJECT_MAPPER, "application/vnd+spotify.test+json");

ServiceHelper service =ServiceHelper.create(entityApp(e), "entity-test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public void testBadResponseAsync() throws Exception {
*/
static void init(Environment environment) {
EntityMiddlewareTest app = new EntityMiddlewareTest();
EntityMiddleware e = EntityMiddleware.jackson(OBJECT_MAPPER);
EntityMiddleware e = EntityMiddleware.forJackson(OBJECT_MAPPER);

Stream<Route<AsyncHandler<Response<ByteString>>>> syncRoutes = Stream.of(
Route.with(e.direct(Person.class), "POST", DIRECT, rc -> app::personDirect),
Expand Down

0 comments on commit 1a99d4b

Please sign in to comment.