Skip to content

Commit

Permalink
support for multipart data (#62)
Browse files Browse the repository at this point in the history
Add support for multipart requests
  • Loading branch information
nateweisz authored Apr 18, 2024
1 parent 3a9f471 commit cd929b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.17.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.0'

implementation 'com.github.mizosoft.methanol:methanol:1.7.0'

implementation 'io.vertx:vertx-web-client:4.5.7'
implementation 'io.vertx:vertx-core:4.5.7'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.mizosoft.methanol.MultipartBodyPublisher;

import java.net.URLEncoder;
import java.net.http.HttpRequest;
Expand Down Expand Up @@ -52,6 +53,17 @@ public DiscordRequestBuilder body(Map<String, Object> payload) {
return this;
}

public DiscordRequestBuilder body(HttpRequest.BodyPublisher body) {
this.body = body;
return this;
}

public DiscordRequestBuilder multipartBody(MultipartBodyPublisher body) {
this.body = body;
this.headers.put("Content-Type", "multipart/form-data");
return this;
}

public DiscordRequestBuilder get() {
this.method = HttpMethod.GET;
return this;
Expand Down

0 comments on commit cd929b5

Please sign in to comment.