Skip to content

Commit

Permalink
feat: Overload DELETE method for URI object (#8486)
Browse files Browse the repository at this point in the history
closes #8483
  • Loading branch information
wetted committed Dec 16, 2022
1 parent 1e98d85 commit 04084ae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Expand Up @@ -45,14 +45,22 @@ 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'))

then:
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'))
Expand Down
12 changes: 12 additions & 0 deletions http/src/main/java/io/micronaut/http/HttpRequest.java
Expand Up @@ -388,6 +388,18 @@ static <T> MutableHttpRequest<T> 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 <T> The Http request type
* @return The {@link MutableHttpRequest} instance
* @see HttpRequestFactory
*/
static <T> MutableHttpRequest<T> DELETE(URI uri) {
return DELETE(uri.toString(), null);
}

/**
* Create a new {@link MutableHttpRequest} for the given method and URI.
*
Expand Down

0 comments on commit 04084ae

Please sign in to comment.