List of usage examples for org.springframework.http ResponseEntity ok
public static BodyBuilder ok()
From source file:org.springframework.cloud.gateway.actuate.GatewayControllerEndpoint.java
@DeleteMapping("/routes/{id}") public Mono<ResponseEntity<Object>> delete(@PathVariable String id) { return this.routeDefinitionWriter.delete(Mono.just(id)) .then(Mono.defer(() -> Mono.just(ResponseEntity.ok().build()))).onErrorResume( t -> t instanceof NotFoundException, t -> Mono.just(ResponseEntity.notFound().build())); }
From source file:org.springframework.cloud.gateway.actuate.GatewayEndpoint.java
@DeleteMapping("/routes/{id}") public Mono<ResponseEntity<Object>> delete(@PathVariable String id) { return this.routeWriter.delete(Mono.just(id)).then(() -> Mono.just(ResponseEntity.ok().build())) .otherwise(t -> t instanceof NotFoundException, t -> Mono.just(ResponseEntity.notFound().build())); }
From source file:org.talend.components.service.rest.impl.PropertiesControllerImpl.java
@Override public ResponseEntity<InputStreamResource> getIcon(String definitionName, DefinitionImageType imageType) { notNull(definitionName, "Definition name cannot be null."); notNull(imageType, "Definition image type cannot be null."); final Definition<?> definition = propertiesHelpers.getDefinition(definitionName); notNull(definition, "Could not find definition of name %s", definitionName); // Undefined and missing icon resources are simply 404. String imagePath = definition.getImagePath(imageType); if (imagePath == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); }/* w w w. j a v a2 s . c om*/ InputStream is = definition.getClass().getResourceAsStream(imagePath); if (is == null) { log.info("The image type %s should exist for %s at %s, but is missing. " + "The component should provide this resource.", imageType, definitionName, imagePath); return new ResponseEntity<>(HttpStatus.NOT_FOUND); } // At this point, we have enough information for a correct response. ResponseEntity.BodyBuilder response = ResponseEntity.ok(); // Add the content type if it can be determined. MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap(); String contentType = mimeTypesMap.getContentType(imagePath); if (contentType != null) { response = response.contentType(MediaType.parseMediaType(contentType)); } return response.body(new InputStreamResource(is)); }