Skip to content

Commit

Permalink
Added cors filter
Browse files Browse the repository at this point in the history
  • Loading branch information
juliuskrah committed Jan 27, 2018
1 parent 9006dab commit 45d0860
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main/java/com/juliuskrah/quartz/web/rest/EmailResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -38,6 +39,7 @@
import lombok.RequiredArgsConstructor;

@RestController
@CrossOrigin(origins = "http://localhost:4200")
@RequestMapping("/api/v1.0")
@RequiredArgsConstructor
public class EmailResource {
Expand All @@ -52,23 +54,23 @@ public class EmailResource {
*/
@PostMapping(path = "/groups/{group}/jobs")
public ResponseEntity<Void> 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<Set<JobDescriptor>> findGroupJobs(@PathVariable String group) {
return ResponseEntity.ok(jobService.findGroupJobs(group));
}

/**
* GET /api/v1.0/jobs
*
Expand All @@ -78,7 +80,7 @@ public ResponseEntity<Set<JobDescriptor>> findGroupJobs(@PathVariable String gro
public ResponseEntity<Set<JobDescriptor>> findJobs() {
return ResponseEntity.ok(jobService.findJobs());
}

/**
* GET /api/v1.0/groups/:group/jobs/:name
*
Expand All @@ -100,7 +102,8 @@ public ResponseEntity<JobDescriptor> findJob(@PathVariable String group, @PathVa
* @return
*/
@PutMapping(path = "/groups/{group}/jobs/{name}")
public ResponseEntity<Void> updateJob(@PathVariable String group, @PathVariable String name, @Valid @RequestBody JobDescriptor descriptor) {
public ResponseEntity<Void> updateJob(@PathVariable String group, @PathVariable String name,
@Valid @RequestBody JobDescriptor descriptor) {
jobService.updateJob(group, name, descriptor);
return ResponseEntity.noContent().build();
}
Expand Down

0 comments on commit 45d0860

Please sign in to comment.