Skip to content

Instantly share code, notes, and snippets.

@njofce
Created March 7, 2021 16:45
Show Gist options
  • Save njofce/3bacca20fdd67ba2f078338a7f0e26e2 to your computer and use it in GitHub Desktop.
Save njofce/3bacca20fdd67ba2f078338a7f0e26e2 to your computer and use it in GitHub Desktop.
@RequestMapping("file")
public interface AsyncFileApi {
@GetMapping("/{id}")
CompletableFuture<FileMetadata> getFile(@PathVariable String id);
@GetMapping("/search")
CompletableFuture<List<FileMetadata>> searchFiles(@RequestParam(name = "name") String name);
@PostMapping("/save")
CompletableFuture<String> saveFile(@RequestBody FileMetadata file);
@PutMapping("/update/{id}")
CompletableFuture<String> updateFile(@RequestBody FileMetadata file, @PathVariable String id);
@DeleteMapping("/delete/{id}")
CompletableFuture<String> updateFile(@PathVariable String id);
}
public static AsyncFileApi getAsyncFileAPI() {
String URL = "http://localhost:8080"; // This must be passed as an ENV variable
return AsyncFeign.asyncBuilder()
.encoder(new JacksonEncoder(apiObjectMapper()))
.decoder(new JacksonDecoder(apiObjectMapper()))
.contract(new SpringMvcContract())
.target(AsyncFileApi.class, URL);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment