List of usage examples for org.springframework.http ResponseEntity ResponseEntity
private ResponseEntity(@Nullable T body, @Nullable MultiValueMap<String, String> headers, Object status)
From source file:com.carlomicieli.jtrains.infrastructure.web.Responses.java
public static <E extends Exception> ResponseEntity<VndErrors> error(E error, HttpStatus httpStatus, String logref) {/*from w w w. j a va 2 s . c o m*/ final HttpHeaders httpHeaders = new HttpHeaders(); return new ResponseEntity<>(new VndErrors(logref, error.getMessage()), httpHeaders, httpStatus); }
From source file:ch.wisv.areafiftylan.utils.ResponseEntityBuilder.java
/** * Create a standard response for all requests to the API * * @param httpStatus The HTTP Status of the response * @param httpHeaders Optional Http Headers for the response. * @param message The message in human readable String format * @param object Optional object related to the request (like a created User) * * @return The ResponseEntity in standard Area FiftyLAN format. *//*from w ww. j ava 2 s .co m*/ public static ResponseEntity<?> createResponseEntity(HttpStatus httpStatus, HttpHeaders httpHeaders, String message, Object object) { Map<String, Object> responseBody = new LinkedHashMap<>(); responseBody.put("status", httpStatus.toString()); responseBody.put("timestamp", LocalDateTime.now().toString()); responseBody.put("message", message); responseBody.put("object", object); if (httpHeaders == null) { httpHeaders = new HttpHeaders(); } return new ResponseEntity<>(responseBody, httpHeaders, httpStatus); }
From source file:monkeys.web.MonkeysController.java
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<List<Monkey>> getAllMonkeys() { List<Monkey> monkeyList = (List<Monkey>) monkeyRepository.findAll(); HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(monkeyList, headers, HttpStatus.OK); }
From source file:monkeys.web.BananasController.java
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<List<Banana>> getAllBananas() { List<Banana> monkeyList = (List<Banana>) bananaRepository.findAll(); HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(monkeyList, headers, HttpStatus.OK); }
From source file:net.eusashead.hateoas.conditional.interceptor.SyncTestController.java
@RequestMapping(method = RequestMethod.GET) public ResponseEntity<String> get() { HttpHeaders headers = new HttpHeaders(); headers.setETag("\"123456\""); return new ResponseEntity<String>("hello", headers, HttpStatus.OK); }
From source file:org.focusns.common.web.WebUtils.java
public static <T> ResponseEntity<T> getResponseEntity(T body, MediaType mediaType) { HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(mediaType); if (body instanceof byte[]) { httpHeaders.setContentLength(((byte[]) body).length); }/*from w w w .jav a 2s. c om*/ return new ResponseEntity<T>(body, httpHeaders, HttpStatus.OK); }
From source file:edu.infsci2560.services.BlogsService.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Iterable<Blog>> list() { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.findAll(), headers, HttpStatus.OK); }
From source file:edu.infsci2560.services.FriendService.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Iterable<Friend>> list() { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.findAll(), headers, HttpStatus.OK); }
From source file:edu.infsci2560.services.DvdsService.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Iterable<Dvd>> list() { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.findAll(), headers, HttpStatus.OK); }
From source file:edu.infsci2560.services.BookService.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Iterable<Book>> list() { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.findAll(), headers, HttpStatus.OK); }