2024-01-03 17:59:04 +00:00
|
|
|
package stirling.software.SPDF.config;
|
|
|
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
|
|
2024-12-24 09:52:53 +00:00
|
|
|
private final EndpointInterceptor endpointInterceptor;
|
|
|
|
|
|
|
|
public WebMvcConfig(EndpointInterceptor endpointInterceptor) {
|
|
|
|
this.endpointInterceptor = endpointInterceptor;
|
|
|
|
}
|
2024-01-03 17:59:04 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
|
|
registry.addInterceptor(endpointInterceptor);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
|
// Handler for external static resources
|
|
|
|
registry.addResourceHandler("/**")
|
2025-01-06 12:41:30 +00:00
|
|
|
.addResourceLocations(
|
|
|
|
"file:" + InstallationPathConfig.getStaticPath(), "classpath:/static/");
|
2024-01-03 17:59:04 +00:00
|
|
|
// .setCachePeriod(0); // Optional: disable caching
|
|
|
|
}
|
|
|
|
}
|