shopify hmac optimise

master
Yixian 3 years ago
parent dda1269b84
commit 9c42322438

@ -1,5 +1,7 @@
package au.com.royalpay.payment.manage.shopify.support; package au.com.royalpay.payment.manage.shopify.support;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.util.ContentCachingRequestWrapper; import org.springframework.web.util.ContentCachingRequestWrapper;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -8,9 +10,12 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
public class ShopifyHttpUtils { public class ShopifyHttpUtils {
private ShopifyHttpUtils(){}
private static final Logger logger = LoggerFactory.getLogger(ShopifyHttpUtils.class);
public static String getRequestBody(HttpServletRequest request) { public static String getRequestBody(HttpServletRequest request) {
if (request instanceof ContentCachingRequestWrapper) { if (request instanceof ContentCachingRequestWrapper) {
logger.info("Shopify Request Cached, read directly");
return new String(((ContentCachingRequestWrapper) request).getContentAsByteArray(), StandardCharsets.UTF_8); return new String(((ContentCachingRequestWrapper) request).getContentAsByteArray(), StandardCharsets.UTF_8);
} }
BufferedReader br = null; BufferedReader br = null;

Loading…
Cancel
Save