byte echo 컨트롤러 추가

This commit is contained in:
yunjy
2022-04-06 09:53:47 +09:00
parent 693e4ee2ce
commit b4d6b2f974
@@ -0,0 +1,42 @@
package com.eactive.httpmockserver;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@RestController
@RequestMapping("/echo")
public class EchoServiceController {
Logger logger = LoggerFactory.getLogger(EchoServiceController.class);
public static int count=0;
public static Object mon=new Object();
public static Map<String, String> responseMap = new ConcurrentHashMap<String, String>();
@PostMapping
@ResponseStatus(value = HttpStatus.OK)
public byte[] service(HttpServletRequest requestEntity) throws FileNotFoundException, IOException{
String readString = null;
byte[] readByte = null;
try {
readByte = IOUtils.toByteArray(requestEntity.getInputStream());
readString = new String(readByte);
} catch (IOException e) {
e.printStackTrace();
}
logger.debug("echo \n"+readString);
return readByte;
}
}