use of org.apache.servicecomb.swagger.extend.annotations.ResponseHeaders in project incubator-servicecomb-java-chassis by apache.
the class CodeFirstJaxrs method response.
@ApiResponse(code = 200, response = User.class, message = "")
@ResponseHeaders({ @ResponseHeader(name = "h1", response = String.class), @ResponseHeader(name = "h2", response = String.class) })
@Path("/response")
@GET
public Response response(InvocationContext c1) {
Response response = Response.createSuccess(Status.ACCEPTED, new User());
Headers headers = response.getHeaders();
headers.addHeader("h1", "h1v " + c1.getContext().toString());
InvocationContext c2 = ContextUtils.getInvocationContext();
headers.addHeader("h2", "h2v " + c2.getContext().toString());
return response;
}
use of org.apache.servicecomb.swagger.extend.annotations.ResponseHeaders in project incubator-servicecomb-java-chassis by apache.
the class ResponseHeadersProcessor method process.
@Override
public void process(Object annotation, OperationGenerator operationGenerator) {
ResponseHeaders responseHeaders = (ResponseHeaders) annotation;
MethodAnnotationProcessor processor = operationGenerator.getContext().findMethodAnnotationProcessor(ResponseHeader.class);
for (ResponseHeader responseHeader : responseHeaders.value()) {
processor.process(responseHeader, operationGenerator);
}
}
use of org.apache.servicecomb.swagger.extend.annotations.ResponseHeaders 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.extend.annotations.ResponseHeaders 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.extend.annotations.ResponseHeaders 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);
}
Aggregations