Files
Backend/src/main/java/xyz/mcutils/backend/controller/MojangController.java
Liam 1cfcce4806
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m52s
etags attempt #2
2024-04-19 21:00:08 +01:00

35 lines
1.3 KiB
Java

package xyz.mcutils.backend.controller;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.CacheControl;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import xyz.mcutils.backend.model.cache.CachedEndpointStatus;
import xyz.mcutils.backend.service.MojangService;
import java.util.concurrent.TimeUnit;
@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;
@ResponseBody
@GetMapping(value = "/status")
public ResponseEntity<CachedEndpointStatus> getStatus() {
CachedEndpointStatus status = mojangService.getMojangApiStatus();
return ResponseEntity.ok()
.cacheControl(CacheControl.maxAge(1, TimeUnit.MINUTES).cachePublic())
.body(status);
}
}