@RequestMapping( value = "/register", method = {RequestMethod.POST}) @ResponseBody public String register(@RequestBody List<Device> devices) { deviceService.putOrDelete(devices); return "success"; }
@RequestMapping(value = "/device/{serialId}/**") public ResponseEntity<?> mirrorRest( @RequestBody(required = false) String body, HttpMethod method, HttpServletRequest request, @PathVariable String serialId) throws URISyntaxException { Device device = deviceService.getDeviceByDid(serialId); String path = DIDRex.matcher(request.getRequestURI()) .replaceFirst("/api/device/" + device.getSerial() + "/"); URI uri = new URI( "http", null, device.getNodeIP(), device.getNodePort(), path, request.getQueryString(), null); LOG.debug("redirect to {}", uri); Class<?> responseType = String.class; for (String part : byteUrls) { if (request.getRequestURI().contains(part)) { responseType = byte[].class; break; } } ResponseEntity<?> responseEntity = restTemplate.exchange(uri, method, new HttpEntity<Object>(body), responseType); return responseEntity; }
@RequestMapping(value = "/device") @ResponseBody public List<Device> devices() { return deviceService.getDevices(); }