-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
10 deletions.
There are no files selected for viewing
33 changes: 23 additions & 10 deletions
33
src/main/java/org/shirakawatyu/handixikebackend/config/MvcConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,42 @@ | ||
package org.shirakawatyu.handixikebackend.config; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.shirakawatyu.handixikebackend.config.interfaces.MatchableHandlerInterceptor; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
/** | ||
* @author ShirakawaTyu | ||
*/ | ||
@Configuration | ||
@RequiredArgsConstructor | ||
public class MvcConfig implements WebMvcConfigurer { | ||
private final List<MatchableHandlerInterceptor> interceptors; | ||
// private final List<MatchableHandlerInterceptor> interceptors; | ||
|
||
@Autowired | ||
private LoginInterceptor loginInterceptor; | ||
@Autowired | ||
private SessionInterceptor sessionInterceptor; | ||
@Autowired | ||
private TimeInterceptor timeInterceptor; | ||
|
||
@Override | ||
public void addInterceptors(InterceptorRegistry registry) { | ||
registry.addInterceptor(sessionInterceptor) | ||
.excludePathPatterns(sessionInterceptor.excludes()) | ||
.addPathPatterns(sessionInterceptor.includes()); | ||
registry.addInterceptor(timeInterceptor) | ||
.excludePathPatterns(timeInterceptor.excludes()) | ||
.addPathPatterns(timeInterceptor.includes()); | ||
registry.addInterceptor(loginInterceptor) | ||
.excludePathPatterns(loginInterceptor.excludes()) | ||
.addPathPatterns(loginInterceptor.includes()); | ||
|
||
Consumer<MatchableHandlerInterceptor> register = (i) -> registry.addInterceptor(i) | ||
.excludePathPatterns(i.excludes()) | ||
.addPathPatterns(i.includes()); | ||
|
||
interceptors.forEach(register); | ||
// Consumer<MatchableHandlerInterceptor> register = (i) -> registry.addInterceptor(i) | ||
// .excludePathPatterns(i.excludes()) | ||
// .addPathPatterns(i.includes()); | ||
// | ||
// interceptors.forEach(register); | ||
} | ||
} |