JavaSpring.apiOriginFilter.mustache Maven / Gradle / Ivy
package {{apiPackage}};
import java.io.IOException;
{{#jakarta}}
import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletResponse;
{{/jakarta}}
{{^jakarta}}
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
{{/jakarta}}
{{>generatedAnnotation}}
public class ApiOriginFilter implements javax.servlet.Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type");
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy