use of org.apache.servicecomb.swagger.invocation.context.InvocationContext in project incubator-servicecomb-java-chassis by apache.
the class CodeFirstSpringmvc method cseResponse.
@ApiResponse(code = 200, response = User.class, message = "")
@ResponseHeaders({ @ResponseHeader(name = "h1", response = String.class), @ResponseHeader(name = "h2", response = String.class) })
@RequestMapping(path = "/cseResponse", method = RequestMethod.GET)
public Response cseResponse(InvocationContext c1) {
Response response = Response.createSuccess(Status.ACCEPTED, new User());
Headers headers = response.getHeaders();
headers.addHeader("h1", "h1v " + c1.getContext().get(Const.SRC_MICROSERVICE).toString());
InvocationContext c2 = ContextUtils.getInvocationContext();
headers.addHeader("h2", "h2v " + c2.getContext().get(Const.SRC_MICROSERVICE).toString());
return response;
}
use of org.apache.servicecomb.swagger.invocation.context.InvocationContext in project incubator-servicecomb-java-chassis by apache.
the class CodeFirstSpringmvc method responseEntity.
@ResponseHeaders({ @ResponseHeader(name = "h1", response = String.class), @ResponseHeader(name = "h2", response = String.class) })
@RequestMapping(path = "/responseEntity", method = RequestMethod.POST)
public ResponseEntity<Date> responseEntity(InvocationContext c1, @RequestAttribute("date") Date date) {
HttpHeaders headers = new HttpHeaders();
headers.add("h1", "h1v " + c1.getContext().get(Const.SRC_MICROSERVICE).toString());
InvocationContext c2 = ContextUtils.getInvocationContext();
headers.add("h2", "h2v " + c2.getContext().get(Const.SRC_MICROSERVICE).toString());
return new ResponseEntity<>(date, headers, HttpStatus.ACCEPTED);
}
use of org.apache.servicecomb.swagger.invocation.context.InvocationContext in project incubator-servicecomb-java-chassis by apache.
the class TestCseHttpEntity method test.
@Test
public void test() {
CseHttpEntity<String> entity = new CseHttpEntity<>(null, null);
entity.addContext("c1", "c1v");
Assert.assertEquals(1, entity.getContext().getContext().size());
Assert.assertEquals("c1v", entity.getContext().getContext("c1"));
InvocationContext context = new InvocationContext();
context.addContext("c2", "c2v");
entity.setContext(context);
Assert.assertEquals(1, entity.getContext().getContext().size());
Assert.assertEquals("c2v", entity.getContext().getContext("c2"));
}
use of org.apache.servicecomb.swagger.invocation.context.InvocationContext in project incubator-servicecomb-java-chassis by apache.
the class CodeFirstSpringmvc method responseEntityPATCH.
@ResponseHeaders({ @ResponseHeader(name = "h1", response = String.class), @ResponseHeader(name = "h2", response = String.class) })
@RequestMapping(path = "/responseEntity", method = RequestMethod.PATCH)
public ResponseEntity<Date> responseEntityPATCH(InvocationContext c1, @RequestAttribute("date") Date date) {
HttpHeaders headers = new HttpHeaders();
headers.add("h1", "h1v " + c1.getContext().get(Const.SRC_MICROSERVICE).toString());
InvocationContext c2 = ContextUtils.getInvocationContext();
headers.add("h2", "h2v " + c2.getContext().get(Const.SRC_MICROSERVICE).toString());
return new ResponseEntity<>(date, headers, HttpStatus.ACCEPTED);
}
use of org.apache.servicecomb.swagger.invocation.context.InvocationContext in project incubator-servicecomb-java-chassis by apache.
the class CodeFirstSpringmvcBase method responseEntity.
public ResponseEntity<Date> responseEntity(InvocationContext c1, Date date) {
HttpHeaders headers = new HttpHeaders();
headers.add("h1", "h1v " + c1.getContext().toString());
InvocationContext c2 = ContextUtils.getInvocationContext();
headers.add("h2", "h2v " + c2.getContext().toString());
return new ResponseEntity<Date>(date, headers, HttpStatus.ACCEPTED);
}
Aggregations