-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from sazzeo/zuul
zuul filter 추가
- Loading branch information
Showing
4 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
51 changes: 51 additions & 0 deletions
51
zuul-service/src/main/java/com/jy/study/zuul/zuulservice/filter/ZuulLoggingFilter.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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.jy.study.zuul.zuulservice.filter; | ||
|
||
import com.netflix.zuul.ZuulFilter; | ||
import com.netflix.zuul.context.RequestContext; | ||
import com.netflix.zuul.exception.ZuulException; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
|
||
//zuul 게이트웨이 필터 | ||
@Slf4j //롬복이 만들어주는 log객체 Logger log = LoggerFactory.getLogger(현재 클래스명.class) | ||
@Component | ||
public class ZuulLoggingFilter extends ZuulFilter { | ||
|
||
//실제 동작할 메소드 지정 | ||
@Override | ||
public Object run() throws ZuulException { | ||
log.info("********** printing logs: "); | ||
|
||
//현재 request 객체를 얻어오는 방법 | ||
RequestContext ctx = RequestContext.getCurrentContext(); | ||
HttpServletRequest request = ctx.getRequest(); | ||
log.info("********** " + request.getRequestURI()); | ||
|
||
return null; | ||
} | ||
|
||
//사전인지, 사후인지 필터 지정 | ||
@Override | ||
public String filterType() { | ||
return "pre"; | ||
} | ||
|
||
//필터 순서 지정 | ||
@Override | ||
public int filterOrder() { | ||
return 1; | ||
} | ||
|
||
|
||
//필터 사용 여부 지정 | ||
@Override | ||
public boolean shouldFilter() { | ||
return true; | ||
} | ||
|
||
|
||
|
||
} |