Class ArticlesController

java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.ArticlesController

@RequestMapping("/api/articles") @RestController public class ArticlesController extends ApiController
This is a REST controller for UCSBDates
  • Constructor Details

    • ArticlesController

      public ArticlesController()
  • Method Details

    • allArticles

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<Article> allArticles()
      List all Articles
      Returns:
      an iterable of Article
    • postArticle

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public Article postArticle(@RequestParam String title, @RequestParam String url, @RequestParam String explanation, @RequestParam String email, @RequestParam("dateAdded") @DateTimeFormat(iso=DATE_TIME) LocalDateTime dateAdded) throws com.fasterxml.jackson.core.JsonProcessingException
      Create a new article
      Parameters:
      title - the title of the article
      url - the url of the article
      explanation - the explanation of the article
      email - the email of the submitter
      dateAdded - the date
      Returns:
      the saved Article
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException