diff --git a/http-client/src/test/groovy/io/micronaut/http/client/HttpDeleteSpec.groovy b/http-client/src/test/groovy/io/micronaut/http/client/HttpDeleteSpec.groovy index fde844c1d18..cbd51f7ff78 100644 --- a/http-client/src/test/groovy/io/micronaut/http/client/HttpDeleteSpec.groovy +++ b/http-client/src/test/groovy/io/micronaut/http/client/HttpDeleteSpec.groovy @@ -45,7 +45,7 @@ class HttpDeleteSpec extends Specification { @Inject MyDeleteClient myDeleteClient - void "test http delete"() { + void "test http delete with URI string"() { when: HttpResponse res = client.toBlocking().exchange(HttpRequest.DELETE('/delete/simple')) @@ -53,6 +53,14 @@ class HttpDeleteSpec extends Specification { res.status == HttpStatus.NO_CONTENT } + void "test http delete with URI object"() { + when: + HttpResponse res = client.toBlocking().exchange(HttpRequest.DELETE(URI.create('/delete/simple'))) + + then: + res.status == HttpStatus.NO_CONTENT + } + void "test http delete with blocking client"() { when: HttpResponse res = client.toBlocking().exchange(HttpRequest.DELETE('/delete/simple')) diff --git a/http/src/main/java/io/micronaut/http/HttpRequest.java b/http/src/main/java/io/micronaut/http/HttpRequest.java index d65553ffb3b..2079b99c656 100644 --- a/http/src/main/java/io/micronaut/http/HttpRequest.java +++ b/http/src/main/java/io/micronaut/http/HttpRequest.java @@ -388,6 +388,18 @@ static MutableHttpRequest DELETE(String uri) { return DELETE(uri, null); } + /** + * Return a {@link MutableHttpRequest} that executes an {@link HttpMethod#DELETE} request for the given URI. + * + * @param uri The URI + * @param The Http request type + * @return The {@link MutableHttpRequest} instance + * @see HttpRequestFactory + */ + static MutableHttpRequest DELETE(URI uri) { + return DELETE(uri.toString(), null); + } + /** * Create a new {@link MutableHttpRequest} for the given method and URI. *