From 45d086055f3552d79c72642117f2c22f2b67bdc1 Mon Sep 17 00:00:00 2001 From: Julius Krah Date: Sat, 27 Jan 2018 20:41:24 +0000 Subject: [PATCH] Added cors filter --- .../juliuskrah/quartz/web/rest/EmailResource.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/juliuskrah/quartz/web/rest/EmailResource.java b/src/main/java/com/juliuskrah/quartz/web/rest/EmailResource.java index 55991d5..8271a0b 100644 --- a/src/main/java/com/juliuskrah/quartz/web/rest/EmailResource.java +++ b/src/main/java/com/juliuskrah/quartz/web/rest/EmailResource.java @@ -21,6 +21,7 @@ import javax.validation.Valid; import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; @@ -38,6 +39,7 @@ import lombok.RequiredArgsConstructor; @RestController +@CrossOrigin(origins = "http://localhost:4200") @RequestMapping("/api/v1.0") @RequiredArgsConstructor public class EmailResource { @@ -52,23 +54,23 @@ public class EmailResource { */ @PostMapping(path = "/groups/{group}/jobs") public ResponseEntity createJob(@PathVariable String group, @Valid @RequestBody JobDescriptor descriptor) { - URI location = ServletUriComponentsBuilder.fromCurrentRequest() - .path("/{job}").buildAndExpand(descriptor.getName()).toUri(); + URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{job}").buildAndExpand(descriptor.getName()).toUri(); jobService.createJob(group, descriptor); return ResponseEntity.created(location).build(); } - + /** * GET /api/v1.0/groups/:group/jobs * * @param group * @return */ + // @CrossOrigin(origins = "*") @GetMapping(path = "/groups/{group}/jobs") public ResponseEntity> findGroupJobs(@PathVariable String group) { return ResponseEntity.ok(jobService.findGroupJobs(group)); } - + /** * GET /api/v1.0/jobs * @@ -78,7 +80,7 @@ public ResponseEntity> findGroupJobs(@PathVariable String gro public ResponseEntity> findJobs() { return ResponseEntity.ok(jobService.findJobs()); } - + /** * GET /api/v1.0/groups/:group/jobs/:name * @@ -100,7 +102,8 @@ public ResponseEntity findJob(@PathVariable String group, @PathVa * @return */ @PutMapping(path = "/groups/{group}/jobs/{name}") - public ResponseEntity updateJob(@PathVariable String group, @PathVariable String name, @Valid @RequestBody JobDescriptor descriptor) { + public ResponseEntity updateJob(@PathVariable String group, @PathVariable String name, + @Valid @RequestBody JobDescriptor descriptor) { jobService.updateJob(group, name, descriptor); return ResponseEntity.noContent().build(); }