shopify request body read

master
Yixian 3 years ago
parent 9c42322438
commit 07dd9a23b6

@ -2,22 +2,18 @@ package au.com.royalpay.payment.manage.shopify.support;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.util.ContentCachingRequestWrapper;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
public class ShopifyHttpUtils {
private ShopifyHttpUtils(){}
private ShopifyHttpUtils() {
}
private static final Logger logger = LoggerFactory.getLogger(ShopifyHttpUtils.class);
public static String getRequestBody(HttpServletRequest request) {
if (request instanceof ContentCachingRequestWrapper) {
logger.info("Shopify Request Cached, read directly");
return new String(((ContentCachingRequestWrapper) request).getContentAsByteArray(), StandardCharsets.UTF_8);
}
BufferedReader br = null;
StringBuilder sb = new StringBuilder("");
try {
@ -39,6 +35,8 @@ public class ShopifyHttpUtils {
}
}
}
return sb.toString();
String body = sb.toString();
logger.debug("Shopify read body |-{}", body);
return body;
}
}

Loading…
Cancel
Save