Fix server icon route producing the wrong file name
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0) (push) Successful in 9s

This commit is contained in:
Braydon 2024-04-09 01:31:48 -04:00
parent 82162b5f63
commit ad51d4d357
2 changed files with 4 additions and 2 deletions

@ -88,7 +88,7 @@ public final class PlayerController {
* @return the skin part texture
* @throws BadRequestException if the extension is invalid
*/
@GetMapping("/{partName}/{query}.{extension}")
@GetMapping(value = "/{partName}/{query}.{extension}", produces = { MediaType.IMAGE_PNG_VALUE, MediaType.IMAGE_JPEG_VALUE })
@ResponseBody
public ResponseEntity<byte[]> getPartTexture(@PathVariable @NonNull String partName, @PathVariable @NonNull String query,
@PathVariable @NonNull String extension, @RequestParam(required = false) String size

@ -32,6 +32,7 @@ import me.braydon.mc.model.MinecraftServer;
import me.braydon.mc.model.cache.CachedMinecraftServer;
import me.braydon.mc.service.MojangService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@ -98,11 +99,12 @@ public final class ServerController {
* @param hostname the hostname of the server
* @return the server icon
*/
@GetMapping("/icon/{hostname}")
@GetMapping(value = "/icon/{hostname}", produces = MediaType.IMAGE_PNG_VALUE)
@ResponseBody
public ResponseEntity<byte[]> getServerFavicon(@PathVariable @NonNull String hostname) {
return ResponseEntity.ok()
.contentType(MediaType.IMAGE_PNG)
.header(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=%s.png".formatted(hostname))
.body(mojangService.getServerFavicon(hostname));
}
}