diff --git a/README.md b/README.md index 17ecadb..528aacb 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,7 @@ If the response object's `contentType` is not explicitly set, the `@Produces` an For methods that should return a `String` or `ByteBuffer` to the client users can create responses like this: ```java ... - import static io.sinistral.proteus.server.ServerResponse.response; + import static io.sinistral.proteus.server.ServerResponse.response; ... @GET @Path("/hello-world") @@ -173,7 +173,7 @@ By default, passing a `String` to the static `ServerResponse.response` helper fu For other types of responses the following demonstrates the preferred style: ```java ... - import static io.sinistral.proteus.server.ServerResponse.response; + import static io.sinistral.proteus.server.ServerResponse.response; ... @GET @Path("/world") @@ -189,7 +189,7 @@ The entity can be set separately as well: ```java ... - import static io.sinistral.proteus.server.ServerResponse.response; + import static io.sinistral.proteus.server.ServerResponse.response; ... @GET @Path("/world") @@ -205,7 +205,7 @@ public ServerResponse getWorld(Integer id, Integer randomNumber ) ```java ... - import static io.sinistral.proteus.server.ServerResponse.response; + import static io.sinistral.proteus.server.ServerResponse.response; ... @GET @Path("/future/user") @@ -220,7 +220,7 @@ In this case a handler will be generated with the following source code: ```java ... - import static io.sinistral.proteus.server.ServerResponse.response; + import static io.sinistral.proteus.server.ServerResponse.response; ... public void handleRequest(final io.undertow.server.HttpServerExchange exchange) throws java.lang.Exception { CompletableFuture> response = examplesController.futureUser(); @@ -243,7 +243,7 @@ Multipart/Form file uploads can be passed to the endpoint methods as a ```java.i Optional parameters are also supported, here is a more complex endpoint demonstrating several parameter types: ```java ... - import static io.sinistral.proteus.server.ServerResponse.response; + import static io.sinistral.proteus.server.ServerResponse.response; ... @GET @Path("/response/parameters/complex/{pathLong}") diff --git a/core/src/test/java/io/sinistral/proteus/swagger/test/controllers/Tests.java b/core/src/test/java/io/sinistral/proteus/swagger/test/controllers/Tests.java index ff54aed..3a2f3ed 100644 --- a/core/src/test/java/io/sinistral/proteus/swagger/test/controllers/Tests.java +++ b/core/src/test/java/io/sinistral/proteus/swagger/test/controllers/Tests.java @@ -37,6 +37,7 @@ import com.google.inject.Singleton; import io.sinistral.proteus.annotations.Blocking; +import io.sinistral.proteus.annotations.Debug; import io.sinistral.proteus.server.ServerRequest; import io.sinistral.proteus.server.ServerResponse; import io.sinistral.proteus.swagger.test.models.User; @@ -334,7 +335,21 @@ public ServerResponse responseUploadFile(ServerRequest request, @For } - + + + + + + + @GET + @Path("response/params/path/{param}") + @Produces(MediaType.TEXT_PLAIN) + public ServerResponse pathParamEndpoint(ServerRequest request, @PathParam("param") String param) { + + return response(param).textPlain(); + } + + @GET @Path("response/debug") public ServerResponse> debugEndpoint(ServerRequest request) diff --git a/core/src/test/java/io/sinistral/proteus/swagger/test/server/TestControllerEndpoints.java b/core/src/test/java/io/sinistral/proteus/swagger/test/server/TestControllerEndpoints.java index dfa5079..ae48ec1 100644 --- a/core/src/test/java/io/sinistral/proteus/swagger/test/server/TestControllerEndpoints.java +++ b/core/src/test/java/io/sinistral/proteus/swagger/test/server/TestControllerEndpoints.java @@ -281,6 +281,27 @@ public void testRedirectMovedPermanentlyCode() given().when().redirects().follow(false).get("tests/redirect/permanent").then().statusCode(301); } + @Test + public void pathParam() + { + given().accept(ContentType.TEXT).when().get("tests/response/params/path/foobar").then().statusCode(200).and().body(containsString("foobar")); + + } + +// @Test +// public void regexPathParam() +// { +// given().accept(ContentType.TEXT).when().get("tests/response/params/regexpath/fooBar").then().statusCode(200).and().body(containsString("fooBar")); +// +// } +// +// @Test +// public void invalidRegexPathParam() +// { +// given().accept(ContentType.TEXT).when().get("tests/response/params/regexpath/fooBar101").then().statusCode(400); +// +// } + @Test public void responseUploadFilePathParameter() { diff --git a/core/src/test/resources/logback-test.xml b/core/src/test/resources/logback-test.xml index aba346f..8763c33 100644 --- a/core/src/test/resources/logback-test.xml +++ b/core/src/test/resources/logback-test.xml @@ -18,7 +18,7 @@ - + @@ -49,7 +49,7 @@ - +