Skip to content

Commit

Permalink
添加接口降级逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
upliveapp committed Apr 10, 2019
1 parent f467843 commit a329d74
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions jswitcher-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
Expand All @@ -30,5 +35,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import com.github.xincao9.jswitcher.core.constant.ConfigConsts;
import java.util.Properties;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
Expand Down Expand Up @@ -95,4 +98,18 @@ public void destroy() throws Exception {
}
}

/**
* 注册Uri拦截器
*
* @return
*/
@ConditionalOnWebApplication
@ConditionalOnClass(FilterRegistrationBean.class)
@Bean
public FilterRegistrationBean filterRegistrationBean(){
FilterRegistrationBean bean = new FilterRegistrationBean();
bean.setFilter(new UriInterceptor(switcherService()));
bean.addUrlPatterns("/*");
return bean;
}
}

0 comments on commit a329d74

Please sign in to comment.