Register REST Filter

master
Rémi Cocula 8 years ago
parent 87a9cb1c12
commit 97f3607b1c
  1. 23
      libresonic-main/src/main/java/org/libresonic/player/boot/Application.java

@ -1,9 +1,12 @@
package org.libresonic.player.boot;
import org.directwebremoting.servlet.DwrServlet;
import org.libresonic.player.filter.RESTFilter;
import org.libresonic.player.security.RESTRequestParameterProcessingFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
@ -19,6 +22,11 @@ import org.springframework.context.annotation.ImportResource;
"classpath:/libresonic-servlet.xml"})
public class Application extends SpringBootServletInitializer {
/**
* Registers the DWR servlet.
*
* @return a registration bean.
*/
@Bean
public ServletRegistrationBean dwrServletRegistrationBean() {
ServletRegistrationBean servlet = new ServletRegistrationBean(new DwrServlet(), "/dwr/*");
@ -26,6 +34,21 @@ public class Application extends SpringBootServletInitializer {
return servlet;
}
/**
* Registers the rest servlet filter.
*
* @return a registration bean.
*/
@Bean
public FilterRegistrationBean restFilterRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(new RESTFilter());
registration.addUrlPatterns("/rest/*");
registration.setName("RESTFilter");
return registration;
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

Loading…
Cancel
Save