Files
Backend/src/main/java/xyz/mcutils/backend/controller/MojangController.java

35 lines
1.3 KiB
Java
Raw Normal View History

2024-04-13 20:53:31 +01:00
package xyz.mcutils.backend.controller;
2024-04-13 15:34:19 +01:00
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
2024-04-19 20:33:12 +01:00
import org.springframework.http.CacheControl;
2024-04-13 15:34:19 +01:00
import org.springframework.http.MediaType;
2024-04-19 20:33:12 +01:00
import org.springframework.http.ResponseEntity;
2024-04-13 17:40:03 +01:00
import org.springframework.web.bind.annotation.GetMapping;
2024-04-13 15:34:19 +01:00
import org.springframework.web.bind.annotation.RequestMapping;
2024-04-13 16:42:21 +01:00
import org.springframework.web.bind.annotation.ResponseBody;
2024-04-13 15:34:19 +01:00
import org.springframework.web.bind.annotation.RestController;
2024-04-13 20:53:31 +01:00
import xyz.mcutils.backend.model.cache.CachedEndpointStatus;
import xyz.mcutils.backend.service.MojangService;
2024-04-13 15:34:19 +01:00
2024-04-19 20:33:12 +01:00
import java.util.concurrent.TimeUnit;
2024-04-13 15:34:19 +01:00
@RestController
@Tag(name = "Mojang Controller", description = "The Mojang Controller is used to get information about the Mojang APIs.")
@RequestMapping(value = "/mojang/", produces = MediaType.APPLICATION_JSON_VALUE)
public class MojangController {
@Autowired
private MojangService mojangService;
2024-04-13 16:42:21 +01:00
@ResponseBody
2024-04-13 17:40:03 +01:00
@GetMapping(value = "/status")
2024-04-19 20:33:12 +01:00
public ResponseEntity<CachedEndpointStatus> getStatus() {
2024-04-19 20:46:30 +01:00
CachedEndpointStatus status = mojangService.getMojangApiStatus();
2024-04-19 20:33:12 +01:00
return ResponseEntity.ok()
2024-04-19 20:51:33 +01:00
.cacheControl(CacheControl.maxAge(1, TimeUnit.MINUTES).cachePublic())
2024-04-19 20:46:30 +01:00
.body(status);
2024-04-13 15:34:19 +01:00
}
}