Merge remote-tracking branch 'origin/master'
This commit is contained in:
+2
-1
@@ -8,6 +8,8 @@ group = 'com.eactive'
|
||||
version = '0.0.1-SNAPSHOT'
|
||||
sourceCompatibility = '1.8'
|
||||
|
||||
compileJava.options.encoding = 'MS949'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
@@ -15,7 +17,6 @@ repositories {
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web-services'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'
|
||||
|
||||
@@ -34,7 +34,8 @@ public class ApiController {
|
||||
private ApiService apiService;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@RequestMapping(value = "/mock-api/**")
|
||||
//@RequestMapping(value = "/mock-api/**")
|
||||
@RequestMapping(value = "/{_:^(?!plugins|dist|favicon.ico).*$}/**")
|
||||
public ResponseEntity<String> mockApi(HttpEntity<String> httpEntity, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
logger.debug("==================================================");
|
||||
@@ -71,7 +72,25 @@ public class ApiController {
|
||||
String.format("Method(%s) not allowed", request.getMethod()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// sleep Àû¿ë
|
||||
if(api.getSleepSeconds() != null) {
|
||||
int sleepSeconds = api.getSleepSeconds().intValue();
|
||||
if (sleepSeconds > 0) {
|
||||
try {
|
||||
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
||||
System.out.println(String.format("Start Sleep %d Seconds.", sleepSeconds));
|
||||
System.out.println("...");
|
||||
Thread.sleep(sleepSeconds * 1000);
|
||||
System.out.println("......");
|
||||
System.out.println(String.format("Finished Sleep %d Seconds.", sleepSeconds));
|
||||
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
||||
if (StringUtils.isNotBlank(api.getResponseContentType())) {
|
||||
responseHeaders.setContentType(MediaType.parseMediaType(api.getResponseContentType()));
|
||||
@@ -80,8 +99,15 @@ public class ApiController {
|
||||
}
|
||||
|
||||
assignResponseHeaders(responseHeaders, api.getResponseHeaders());
|
||||
|
||||
// status code Àû¿ë
|
||||
int responseStatusCode = 200;
|
||||
if (api.getResponseStatusCode() != null) {
|
||||
responseStatusCode = api.getResponseStatusCode().intValue();
|
||||
System.out.println("Response Status Code=" + responseStatusCode);
|
||||
}
|
||||
|
||||
return new ResponseEntity<String>(assignResponseBody(api), responseHeaders, HttpStatus.OK);
|
||||
return new ResponseEntity<String>(assignResponseBody(api), responseHeaders, responseStatusCode);
|
||||
}
|
||||
|
||||
private String assignServiceValue(HttpEntity<String> httpEntity, HttpServletRequest request, String url) {
|
||||
|
||||
@@ -10,7 +10,9 @@ import javax.persistence.Id;
|
||||
import javax.persistence.Index;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Positive;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Entity
|
||||
@@ -46,6 +48,12 @@ public class ApiInfo implements Serializable {
|
||||
@Column(length = 5000)
|
||||
private String responseHeaders;
|
||||
|
||||
@Digits(fraction = 0, integer = 3)
|
||||
private Integer responseStatusCode;
|
||||
|
||||
@Positive
|
||||
private Integer sleepSeconds;
|
||||
|
||||
@Column(length = 5000)
|
||||
private String responseBody1;
|
||||
|
||||
@@ -116,6 +124,22 @@ public class ApiInfo implements Serializable {
|
||||
this.responseHeaders = responseHeaders;
|
||||
}
|
||||
|
||||
public Integer getResponseStatusCode() {
|
||||
return responseStatusCode;
|
||||
}
|
||||
|
||||
public void setResponseStatusCode(Integer responseStatusCode) {
|
||||
this.responseStatusCode = responseStatusCode;
|
||||
}
|
||||
|
||||
public Integer getSleepSeconds() {
|
||||
return sleepSeconds;
|
||||
}
|
||||
|
||||
public void setSleepSeconds(Integer sleepSeconds) {
|
||||
this.sleepSeconds = sleepSeconds;
|
||||
}
|
||||
|
||||
public String getResponseBody1() {
|
||||
return responseBody1;
|
||||
}
|
||||
@@ -136,7 +160,8 @@ public class ApiInfo implements Serializable {
|
||||
public String toString() {
|
||||
return "ApiInfo [id=" + id + ", apiGroupName=" + apiGroupName + ", apiName=" + apiName + ", url=" + url
|
||||
+ ", serviceValue=" + serviceValue + ", method=" + method + ", responseContentType="
|
||||
+ responseContentType + ", responseHeaders=" + responseHeaders + ", responseBody1=" + responseBody1
|
||||
+ responseContentType + ", responseHeaders=" + responseHeaders + ", responseStatusCode="
|
||||
+ responseStatusCode + ", sleepSeconds=" + sleepSeconds + ", responseBody1=" + responseBody1
|
||||
+ ", responseBody2=" + responseBody2 + "]";
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -129,6 +129,30 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label">응답 Status Code</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" th:field="*{responseStatusCode}"
|
||||
class="form-control"> <span
|
||||
th:if="${#fields.hasErrors('responseStatusCode')}" th:errors="*{responseStatusCode}"
|
||||
class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label">Sleep 타임(초)</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" th:field="*{sleepSeconds}"
|
||||
class="form-control"> <span
|
||||
th:if="${#fields.hasErrors('sleepSeconds')}" th:errors="*{sleepSeconds}"
|
||||
class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group row">
|
||||
|
||||
Reference in New Issue
Block a user