Skip to content

Instantly share code, notes, and snippets.

@dvallin
Created November 29, 2017 16:46
Show Gist options
  • Save dvallin/f6d3751bc7725b8dce4cdac00f98c60e to your computer and use it in GitHub Desktop.
Save dvallin/f6d3751bc7725b8dce4cdac00f98c60e to your computer and use it in GitHub Desktop.
@RestController
public class TaskApi {
private static final String BASE_REST_PATH = "/api";
private static final String API_PATH = "/tasks";
private static final String APPLICATION_JSON = "application/json; charset=UTF-8";
@Autowired
TasksService service;
@CrossOrigin(origins = "http://localhost:8080")
@RequestMapping(
value = BASE_REST_PATH + API_PATH,
method = RequestMethod.GET,
produces = APPLICATION_JSON
)
public Flux<Task> list() {
return this.service.list();
}
@CrossOrigin(origins = "http://localhost:8080")
@RequestMapping(
value = BASE_REST_PATH + API_PATH + "/add",
method = RequestMethod.POST,
consumes = APPLICATION_JSON,
produces = APPLICATION_JSON
)
public Mono<Task> add(@RequestBody @Validated final AddTask body) {
return this.service.addTask(body);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment