Skip to content

Commit

Permalink
Merge pull request #234 from kookmin-sw/feature/be/#230-Loggig
Browse files Browse the repository at this point in the history
fix: Gradlew 개행 문제 해결
  • Loading branch information
mclub4 authored May 22, 2024
2 parents 78861be + b947387 commit cd6447e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.nio.charset.StandardCharsets;
Expand All @@ -26,14 +23,14 @@ public class GlobalLoggingFilter {
@Order(-1)
public GlobalFilter preLoggingFilter() {
return (exchange, chain) -> {
log.info("왜 안되는걸까?");
ServerHttpRequest request = exchange.getRequest();
return DataBufferUtils.join(request.getBody())
.flatMap(dataBuffer -> {
byte[] bodyBytes = new byte[dataBuffer.readableByteCount()];
dataBuffer.read(bodyBytes);
DataBufferUtils.release(dataBuffer);
String bodyString = new String(bodyBytes, StandardCharsets.UTF_8);

String jsonBody;
try {
Object json = objectMapper.readValue(bodyString, Object.class);
Expand All @@ -44,10 +41,18 @@ public GlobalFilter preLoggingFilter() {

log.info("Global Filter Start: request id -> {}", request.getId());
log.info("Request: {} {}", request.getMethod(), request.getURI());
?");
return chain.filter(exchange).then(Mono.fromRunnable(() -> {
log.info("Response: " + exchange.getResponse().getStatusCode());
}));
log.info("Request Body: {}", jsonBody);

return chain.filter(exchange);
});
};
}

@Bean
@Order(Ordered.LOWEST_PRECEDENCE)
public GlobalFilter postLoggingFilter() {
return (exchange, chain) -> chain.filter(exchange).then(Mono.fromRunnable(() -> {
log.info("Response: {}", exchange.getResponse().getStatusCode());
}));
}
}
42 changes: 0 additions & 42 deletions back/nginx/test.conf.template

This file was deleted.

0 comments on commit cd6447e

Please sign in to comment.