etags attempt #2
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m52s
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m52s
This commit is contained in:
parent
46d4a53b11
commit
1cfcce4806
@ -12,8 +12,6 @@ import java.net.http.HttpClient;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@Log4j2
|
||||
@SpringBootApplication
|
||||
|
@ -6,9 +6,11 @@ import lombok.NonNull;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.web.filter.ShallowEtagHeaderFilter;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@ -28,6 +30,14 @@ public class Config {
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean<ShallowEtagHeaderFilter> shallowEtagHeaderFilter() {
|
||||
FilterRegistrationBean<ShallowEtagHeaderFilter> filterRegistrationBean = new FilterRegistrationBean<>(new ShallowEtagHeaderFilter());
|
||||
filterRegistrationBean.addUrlPatterns("/*");
|
||||
filterRegistrationBean.setName("etagFilter");
|
||||
return filterRegistrationBean;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WebMvcConfigurer configureCors() {
|
||||
return new WebMvcConfigurer() {
|
||||
|
@ -29,7 +29,6 @@ public class MojangController {
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.cacheControl(CacheControl.maxAge(1, TimeUnit.MINUTES).cachePublic())
|
||||
.eTag(String.valueOf(status.hashCode()))
|
||||
.body(status);
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ public class PlayerController {
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.cacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic())
|
||||
.eTag(String.valueOf(player.hashCode()))
|
||||
.body(player);
|
||||
}
|
||||
|
||||
@ -47,7 +46,6 @@ public class PlayerController {
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.cacheControl(CacheControl.maxAge(6, TimeUnit.HOURS).cachePublic())
|
||||
.eTag(String.valueOf(player.hashCode()))
|
||||
.body(player);
|
||||
}
|
||||
|
||||
@ -67,7 +65,6 @@ public class PlayerController {
|
||||
.cacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic())
|
||||
.contentType(MediaType.IMAGE_PNG)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, dispositionHeader.formatted(player.getUsername()))
|
||||
.eTag(String.valueOf(player.hashCode()))
|
||||
.body(playerService.getSkinPart(player, part, overlays, size).getBytes());
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import xyz.mcutils.backend.model.cache.CachedMinecraftServer;
|
||||
import xyz.mcutils.backend.service.MojangService;
|
||||
import xyz.mcutils.backend.service.ServerService;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -39,7 +38,6 @@ public class ServerController {
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.cacheControl(CacheControl.maxAge(5, TimeUnit.MINUTES).cachePublic())
|
||||
.eTag(String.valueOf(server.hashCode()))
|
||||
.body(server);
|
||||
}
|
||||
|
||||
@ -55,7 +53,6 @@ public class ServerController {
|
||||
.cacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic())
|
||||
.contentType(MediaType.IMAGE_PNG)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, dispositionHeader.formatted(hostname))
|
||||
.eTag(String.valueOf(Arrays.hashCode(favicon)))
|
||||
.body(favicon);
|
||||
}
|
||||
|
||||
@ -65,7 +62,6 @@ public class ServerController {
|
||||
@Parameter(description = "The hostname of the server", example = "aetheria.cc") @PathVariable String hostname) {
|
||||
return ResponseEntity.ok()
|
||||
.cacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic())
|
||||
.eTag(String.valueOf(hostname.hashCode()))
|
||||
.body(Map.of(
|
||||
"blocked", mojangService.isServerBlocked(hostname)
|
||||
));
|
||||
|
@ -1,8 +1,10 @@
|
||||
package xyz.mcutils.backend.model.cache;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||
import lombok.*;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.redis.core.RedisHash;
|
||||
import xyz.mcutils.backend.common.CachedResponse;
|
||||
|
@ -2,7 +2,10 @@ package xyz.mcutils.backend.model.cache;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||
import lombok.*;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.redis.core.RedisHash;
|
||||
import xyz.mcutils.backend.common.CachedResponse;
|
||||
|
@ -2,7 +2,9 @@ package xyz.mcutils.backend.model.cache;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||
import lombok.*;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.redis.core.RedisHash;
|
||||
import xyz.mcutils.backend.common.CachedResponse;
|
||||
|
@ -1,7 +1,9 @@
|
||||
package xyz.mcutils.backend.model.cache;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.*;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.redis.core.RedisHash;
|
||||
import xyz.mcutils.backend.common.CachedResponse;
|
||||
|
@ -1,8 +1,9 @@
|
||||
package xyz.mcutils.backend.model.mojang;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Map;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Getter @Setter @EqualsAndHashCode
|
||||
|
@ -11,7 +11,9 @@ import lombok.extern.log4j.Log4j2;
|
||||
import net.jodah.expiringmap.ExpirationPolicy;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import xyz.mcutils.backend.common.*;
|
||||
import xyz.mcutils.backend.common.EnvironmentUtils;
|
||||
import xyz.mcutils.backend.common.ExpiringSet;
|
||||
import xyz.mcutils.backend.common.WebRequest;
|
||||
import xyz.mcutils.backend.model.cache.CachedEndpointStatus;
|
||||
import xyz.mcutils.backend.model.mojang.EndpointStatus;
|
||||
import xyz.mcutils.backend.model.token.MojangProfileToken;
|
||||
@ -24,8 +26,6 @@ import java.net.InetAddress;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.Timer;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service @Log4j2 @Getter
|
||||
|
Loading…
x
Reference in New Issue
Block a user