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:edu.infsci2560.services.LocationsService.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Iterable<Location>> list() { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.findAll(), headers, HttpStatus.OK); }
From source file:github.priyatam.springrest.resource.DriverResource.java
@RequestMapping(method = RequestMethod.GET, value = "/driver/{licenseNo}") @ResponseBody//from www . ja v a2 s. c o m public ResponseEntity<Driver> getDriver(@PathVariable String licenseNo) { logger.debug(String.format("Retrieving Driver %s :", licenseNo)); Driver driver = persistenceHelper.loadDriverByLicenseNum(licenseNo); if (driver == null) { logger.warn("No Driver found"); return new ResponseEntity<Driver>(null, new HttpHeaders(), HttpStatus.NOT_FOUND); } // Convert to Restful Resource, update ETag and HATEOAS references responseBuilder.toDriver(Lists.newArrayList(driver)); return new ResponseEntity<Driver>(driver, HttpStatus.OK); }
From source file:com.codekul.simpleboot.controller.ControllerRestServices.java
@RequestMapping(value = "/user", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public /*@ResponseBody*/ ResponseEntity<User> userInfo() { User userBody = new User(); userBody.setUserName("Android"); userBody.setPassword("android"); HttpHeaders headers = new HttpHeaders(); ResponseEntity<User> entity = new ResponseEntity<>(userBody, headers, HttpStatus.OK); return entity; }
From source file:org.zalando.riptide.TypedCondition.java
private ResponseEntity<I> toResponseEntity(final I entity, final ClientHttpResponse response) throws IOException { return new ResponseEntity<>(entity, response.getHeaders(), response.getStatusCode()); }
From source file:net.eusashead.hateoas.conditional.interceptor.AsyncTestController.java
@RequestMapping(method = RequestMethod.GET) public Callable<ResponseEntity<String>> get() { return new Callable<ResponseEntity<String>>() { @Override/* www . j av a 2 s .c o m*/ public ResponseEntity<String> call() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setETag("\"123456\""); return new ResponseEntity<String>("hello", headers, HttpStatus.OK); } }; }
From source file:com.biz.report.controller.RepReportController.java
@RequestMapping(value = "/reps") private ResponseEntity<List<String>> readReps() { List<String> list = repReportService.readReps(); HttpHeaders headers = new HttpHeaders(); headers.add("success", "Success"); return new ResponseEntity<List<String>>(list, headers, HttpStatus.OK); }
From source file:monkeys.web.MonkeysController.java
@RequestMapping(method = RequestMethod.GET, value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Monkey> getMonkey(@PathVariable Long id) { Monkey monkey = monkeyRepository.findOne(id); HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(monkey, headers, HttpStatus.OK); }
From source file:com.isalnikov.controller.MessageController.java
@RequestMapping(value = { "/message/{code}" }, method = RequestMethod.GET) @ResponseBody/* www. j ava 2 s . c o m*/ public ResponseEntity index(@PathVariable("code") String code, Locale locale) { String result = messageSource.getMessage(code, new Object[] {}, locale); System.out.println(String.format("%s : %s", locale.getLanguage(), result)); String res = String.format("%s : %s", locale.getLanguage(), messageHelper.getMessage(code)); HttpHeaders headers = new HttpHeaders(); headers.add("Content-type", "application/json;charset=UTF-8"); ResponseEntity responseEntity = new ResponseEntity<>(res, headers, HttpStatus.OK); return responseEntity; }
From source file:edu.infsci2560.services.BlogsService.java
@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Blog> list(@PathVariable("id") Long id) { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.findOne(id), headers, HttpStatus.OK); }
From source file:monkeys.web.BananasController.java
@RequestMapping(method = RequestMethod.GET, value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Banana> getBanana(@PathVariable Long id) { Banana banana = bananaRepository.findOne(id); HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(banana, headers, HttpStatus.OK); }