1
0
mirror of https://github.com/Stirling-Tools/Stirling-PDF.git synced 2024-11-08 08:50:10 +01:00
Stirling-PDF/src/main/java/stirling/software/SPDF/config/EndpointInterceptor.java

26 lines
888 B
Java
Raw Normal View History

2023-05-16 23:44:53 +02:00
package stirling.software.SPDF.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@Component
public class EndpointInterceptor implements HandlerInterceptor {
@Autowired
private EndpointConfiguration endpointConfiguration;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
String requestURI = request.getRequestURI();
if (!endpointConfiguration.isEndpointEnabled(requestURI)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "This endpoint is disabled");
return false;
}
return true;
}
2023-05-18 00:58:15 +02:00
}