Add more informative 404 message

This commit is contained in:
2025-12-24 14:13:12 +00:00
parent 52d1984478
commit bd1176fbc3
2 changed files with 4 additions and 5 deletions

View File

@@ -20,7 +20,7 @@ public class ShortLinkController {
}
@GetMapping("/{code}")
public ResponseEntity<Void> redirectToUrl(@PathVariable String code) {
public ResponseEntity<String> redirectToUrl(@PathVariable String code) {
ShortLink sl = shortLinkRepository.findByCode(code).orElse(null);
if (sl != null) {
sl.setClicks(sl.getClicks() + 1);
@@ -30,7 +30,7 @@ public class ShortLinkController {
.location(URI.create(sl.getUrl()))
.build();
}
return ResponseEntity.notFound().build();
return ResponseEntity.status(404).body("The requested link was not found on the server");
}
@PostMapping