List of usage examples for org.springframework.http RequestEntity post
public static BodyBuilder post(URI url)
From source file:io.spring.initializr.actuate.stat.ProjectGenerationStatPublisher.java
@EventListener @Async//from ww w .j a va 2s.c om public void handleEvent(ProjectRequestEvent event) { String json = null; try { ProjectRequestDocument document = documentFactory.createDocument(event); if (log.isDebugEnabled()) { log.debug("Publishing " + document); } json = toJson(document); RequestEntity<String> request = RequestEntity.post(this.statsProperties.getElastic().getEntityUrl()) .contentType(MediaType.APPLICATION_JSON).body(json); this.retryTemplate.execute((RetryCallback<Void, RuntimeException>) context -> { restTemplate.exchange(request, String.class); return null; }); } catch (Exception ex) { log.warn(String.format("Failed to publish stat to index, document follows %n%n%s%n", json), ex); } }
From source file:org.springframework.http.server.reactive.ServerHttpsRequestIntegrationTests.java
@Test public void checkUri() throws Exception { URI url = new URI("https://localhost:" + port + "/foo?param=bar"); RequestEntity<Void> request = RequestEntity.post(url).build(); ResponseEntity<Void> response = this.restTemplate.exchange(request, Void.class); assertEquals(HttpStatus.OK, response.getStatusCode()); }