content: package kr.co.fastcampus.eatgo.interfaces;
  
  import kr.co.fastcampus.eatgo.application.CategoryService;
  import kr.co.fastcampus.eatgo.domain.Category;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.http.ResponseEntity;
  import org.springframework.web.bind.annotation.*;
  
  import java.net.URI;
  import java.net.URISyntaxException;
  import java.util.List;
  
  @CrossOrigin
  @RestController
  public class CategoryController {
  
      @Autowired
      private CategoryService categoryService;
  
      @GetMapping("/categories")
      public List<Category> list() {
          List<Category> regions = categoryService.getCategories();
  
          return regions;
      }
  
      @PostMapping("/categories")
      public ResponseEntity<?> create(
              @RequestBody Category resource
      ) throws URISyntaxException {
          String name = resource.getName();
  
          Category category = categoryService.addCategory(name);
  
          String url = "/categories/" + category.getId();
          return ResponseEntity.created(new URI(url)).body("{}");
      }
  
  }
  