Guest User

Untitled

a guest
Jun 17th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. HttpErrorResponse {headers: HttpHeaders, status: 405, statusText: "OK", url: "http://localhost:8080/api/delete/1", ok: false, …}
  2.  
  3. //Rest Controller
  4.  
  5. @PutMapping(path = "edit/{id}", produces = MediaType.APPLICATION_JSON_VALUE,
  6. consumes = MediaType.APPLICATION_JSON_VALUE)
  7. public void editRecipient(@PathVariable("id") Long id,
  8. @RequestBody RecipientEntity recipient){
  9. service.updateRecipient(id, recipient);
  10. }
  11.  
  12. @DeleteMapping(path = "delete/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
  13. public void deleteRecipient(@PathVariable("id") Long id) throws NotFoundException {
  14. service.deleteRecipient(id);
  15. }
  16.  
  17. @Configuration
  18. public class WebConfig {
  19.  
  20. @Bean
  21. public FilterRegistrationBean corsFilter() {
  22. UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
  23. CorsConfiguration config = new CorsConfiguration();
  24. config.setAllowCredentials(true);
  25. config.addAllowedOrigin("*");
  26. config.addAllowedHeader("*");
  27. config.addAllowedMethod("*");
  28. source.registerCorsConfiguration("/**", config);
  29. FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
  30. bean.setOrder(0);
  31. return bean;
  32. }
Add Comment
Please, Sign In to add comment