|
@@ -1,28 +1,39 @@
|
|
|
package com.text.service;
|
|
|
|
|
|
import com.mars.common.annotation.bean.MarsBean;
|
|
|
+import com.mars.iserver.constant.HttpConstant;
|
|
|
import com.mars.iserver.server.impl.MarsHttpExchange;
|
|
|
-import com.mars.iserver.server.model.HttpHeaders;
|
|
|
-import com.mars.server.server.request.HttpMarsRequest;
|
|
|
import com.mars.server.server.request.HttpMarsResponse;
|
|
|
import com.text.api.vo.MessageVO;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
+import java.util.Locale;
|
|
|
+import java.util.TimeZone;
|
|
|
|
|
|
@MarsBean
|
|
|
public class TestService {
|
|
|
|
|
|
- private Logger logger = LoggerFactory.getLogger(TestService.class);
|
|
|
+ private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("E, dd MMM yyyy H:m:s z", Locale.US);
|
|
|
|
|
|
public MessageVO json(HttpMarsResponse response){
|
|
|
- MessageVO messageVO = new MessageVO();
|
|
|
- messageVO.setMessage("Hello, World!");
|
|
|
+ /*
|
|
|
+ Because this is a purely front-end and back-end separation framework,
|
|
|
+ the response header will include cross-domain by default.
|
|
|
+ In order to adapt to the tfb test, these default headers are removed here.
|
|
|
+ */
|
|
|
+ response.geNativeResponse(MarsHttpExchange.class).getResponseHeaders().clear();
|
|
|
+
|
|
|
+ // Add the header required by tfb
|
|
|
+ String str = simpleDateFormat.format(new Date());
|
|
|
|
|
|
+ response.setHeader("Content-Type", HttpConstant.RESPONSE_CONTENT_TYPE);
|
|
|
response.setHeader("Server","Martian");
|
|
|
- response.setHeader("Date", "Wed, "+new Date().toGMTString());
|
|
|
+ response.setHeader("Date", str);
|
|
|
|
|
|
+
|
|
|
+ MessageVO messageVO = new MessageVO();
|
|
|
+ messageVO.setMessage("Hello, World!");
|
|
|
return messageVO;
|
|
|
}
|
|
|
}
|