world controller: return service unavailable if world list isn't loaded

This commit is contained in:
Adam
2020-03-26 10:42:54 -04:00
parent 09c5a1d951
commit b0a7e779be

View File

@@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit;
import net.runelite.http.api.worlds.WorldResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.CacheControl;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
@@ -45,8 +46,15 @@ public class WorldController
private WorldResult worldResult;
@GetMapping
public ResponseEntity<WorldResult> listWorlds() throws IOException
public ResponseEntity<WorldResult> listWorlds()
{
if (worldResult == null)
{
return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
.cacheControl(CacheControl.noCache())
.build();
}
return ResponseEntity.ok()
.cacheControl(CacheControl.maxAge(10, TimeUnit.MINUTES).cachePublic())
.body(worldResult);