mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-04 07:28:26 +01:00
Added ResponseBuilder#setContent(WebResource)
This commit is contained in:
parent
4fd19bbc5e
commit
38bb2ce61c
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.web.resolver;
|
||||
|
||||
import com.djrapitops.plan.delivery.web.resource.WebResource;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
@ -75,6 +76,10 @@ public class ResponseBuilder {
|
||||
return setStatus(302).setHeader("Location", url).setContent(new byte[0]);
|
||||
}
|
||||
|
||||
public ResponseBuilder setContent(WebResource resource) {
|
||||
return setContent(resource.asBytes());
|
||||
}
|
||||
|
||||
public ResponseBuilder setContent(byte[] bytes) {
|
||||
response.bytes = bytes;
|
||||
return setHeader("Content-Length", bytes.length)
|
||||
|
@ -204,7 +204,7 @@ public class ResponseFactory {
|
||||
try {
|
||||
return Response.builder()
|
||||
.setMimeType(MimeType.IMAGE)
|
||||
.setContent(getResource(fileName).asBytes())
|
||||
.setContent(getResource(fileName))
|
||||
.setStatus(200)
|
||||
.build();
|
||||
} catch (UncheckedIOException e) {
|
||||
@ -228,7 +228,7 @@ public class ResponseFactory {
|
||||
try {
|
||||
return Response.builder()
|
||||
.setMimeType(type)
|
||||
.setContent(getResource(fileName).asBytes())
|
||||
.setContent(getResource(fileName))
|
||||
.build();
|
||||
} catch (UncheckedIOException e) {
|
||||
return notFound404("Font File not found from jar: " + fileName + ", " + e.toString());
|
||||
@ -243,7 +243,7 @@ public class ResponseFactory {
|
||||
try {
|
||||
return Response.builder()
|
||||
.setMimeType(MimeType.FAVICON)
|
||||
.setContent(getResource("favicon.ico").asBytes())
|
||||
.setContent(getResource("favicon.ico"))
|
||||
.build();
|
||||
} catch (UncheckedIOException e) {
|
||||
return forInternalError(e, "Could not read favicon");
|
||||
|
Loading…
Reference in New Issue
Block a user