Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overload DELETE method for URI object #8486

Merged
merged 1 commit into from Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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