-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
86c97e7
commit 76c4579
Showing
7 changed files
with
68 additions
and
46 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
Binary file not shown.
Binary file not shown.
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,55 @@ | ||
package com.suit4j.app.configs; | ||
|
||
import org.bot4j.telegram.message.MessageFactory; | ||
import org.botwrap4j.common.BotWrap4j; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.servlet.HandlerInterceptor; | ||
import org.springframework.web.servlet.ModelAndView; | ||
import org.unify4j.common.Json4j; | ||
import org.unify4j.common.Request4j; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
@SuppressWarnings({"NullableProblems"}) | ||
@Component | ||
public class HttpConfig implements HandlerInterceptor { | ||
protected static final Logger logger = LoggerFactory.getLogger(HttpConfig.class); | ||
|
||
@Override | ||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | ||
logger.info("Incoming request, {} URI: {}, params: {}", request.getMethod(), request.getRequestURI(), Json4j.toJson(request.getParameterMap())); | ||
return true; | ||
} | ||
|
||
@Override | ||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { | ||
} | ||
|
||
@Override | ||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception e) throws Exception { | ||
logger.info("Outgoing response, status: {} ({}), {} URI: {} and params: {}", | ||
response.getStatus(), HttpStatus.valueOf(response.getStatus()).getReasonPhrase(), | ||
request.getMethod(), request.getRequestURI(), Json4j.toJson(request.getParameterMap())); | ||
if (e != null) { | ||
logger.error("afterCompletion, outgoing response raised an exception: {}", e.getMessage(), e); | ||
} | ||
BotWrap4j.telegramProvider().sendMessageSilent("worker_logging", | ||
MessageFactory.http() | ||
.status(response.getStatus()) | ||
.method(request.getMethod()) | ||
.baseUrl(Request4j.getBaseUrl(request)) | ||
.path(request.getRequestURI()) | ||
.query(request.getParameterMap()) | ||
.apiDesc(HttpConfig.class.getName()) | ||
.cause(e) | ||
.requestId(Request4j.getSessionId(request)) | ||
.header(Request4j.getHeaders(request)) | ||
.startTime() | ||
.endTime() | ||
); | ||
} | ||
} |
39 changes: 0 additions & 39 deletions
39
src/main/java/com/suit4j/app/configs/HttpInterceptorConfig.java
This file was deleted.
Oops, something went wrong.
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