diff --git a/src/main/java/cc/fascinated/backend/controller/IndexController.java b/src/main/java/cc/fascinated/backend/controller/IndexController.java index bf71ef5..410be59 100644 --- a/src/main/java/cc/fascinated/backend/controller/IndexController.java +++ b/src/main/java/cc/fascinated/backend/controller/IndexController.java @@ -26,20 +26,20 @@ public class IndexController { this.pasteService = pasteService; } + @GetMapping(value = "/") + public String home() { + return "index"; + } + /** * This is to allow for Hastebin compatibility. */ @PostMapping(value = "/documents") - public ResponseEntity uploadPaste(@RequestBody String content, @RequestHeader(HttpHeaders.CONTENT_TYPE) String contentType) { + public ResponseEntity uploadPaste(@RequestBody String content, @RequestHeader(value = HttpHeaders.CONTENT_TYPE, required = false) String contentType) { String id = pasteService.createPaste(content, contentType); return ResponseEntity.ok(Map.of("key", id)); } - @GetMapping(value = "/") - public String home() { - return "index"; - } - @GetMapping(value = "/{id}") public String paste(@PathVariable String id, Model model) { try { diff --git a/src/main/java/cc/fascinated/backend/service/PasteService.java b/src/main/java/cc/fascinated/backend/service/PasteService.java index e67b904..90d1e0d 100644 --- a/src/main/java/cc/fascinated/backend/service/PasteService.java +++ b/src/main/java/cc/fascinated/backend/service/PasteService.java @@ -56,7 +56,7 @@ public class PasteService { } // Ensure the paste content type is valid. - if (contentType.contains("image") || contentType.contains("video") || contentType.contains("audio")) { + if (contentType != null && (contentType.contains("image") || contentType.contains("video") || contentType.contains("audio"))) { log.info("Paste content type is not supported. (content type: {})", contentType); throw new BadRequestException("The paste content type is not supported, not uploading..."); }