27 lines
591 B
Java
27 lines
591 B
Java
package com.example.hangry;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
@RestController
|
|
@RequestMapping("/api/recipes")
|
|
public class RecipeController {
|
|
|
|
private final RecipeService recipeService;
|
|
|
|
public RecipeController(RecipeService recipeService) {
|
|
this.recipeService = recipeService;
|
|
}
|
|
|
|
@GetMapping
|
|
public List<Recipe> getAllRecipes() {
|
|
return recipeService.getAllRecipes();
|
|
}
|
|
|
|
@PostMapping
|
|
public Recipe createRecipe(@RequestBody Recipe recipe) {
|
|
return recipeService.createRecipe(recipe);
|
|
}
|
|
}
|