This project was imported from an existing recipe blog application that I own. The main objective behind this endeavor was to create two distinct projects. The first one serves as a showcase, utilizing Thymeleaf to render and present the recipes in a visually appealing manner. The second project, on the other hand, focuses on providing a RESTful API to expose the recipe data.
This second project exposes the recipe data through a RESTful API, providing a straightforward way for developers and other applications to access and utilize the recipe information programmatically. This API can be easily integrated into various applications, such as mobile apps, front-end frameworks, or any other platforms that can consume RESTful services.
The purpose of creating these two projects is to illustrate different methods of interacting with the recipe blog data. By having a Thymeleaf-powered showcase and a RESTful API, this project showcases the versatility and potential uses of the underlying data.
-
Create Recipe Endpoint:
curl -X POST -H "Content-Type: application/json" -d '{ "title": "Delicious Cake", "description": "A mouthwatering cake recipe", "categories": ["Dessert", "Baking"], "ingredients": ["Flour", "Sugar", "Eggs", "Butter"] }' http://localhost:8080/api/v1/recipeblog/create-recipe
-
List All Recipes Endpoint:
curl http://localhost:8080/api/v1/recipeblog
-
List All Recipes According to Category Endpoint:
curl http://localhost:8080/api/v1/recipeblog/category/{id}
Replace
{id}
with the actualcategoryId
you want to retrieve recipes for. For example, if thecategoryId
is 1, the request will be:curl http://localhost:8080/api/v1/recipeblog/category/1
-
Get Recipe by ID Endpoint:
curl http://localhost:8080/api/v1/recipeblog/recipe/{id}
Replace
{id}
with the actualrecipeId
you want to retrieve. For example, if therecipeId
is 123, the request will be:curl http://localhost:8080/api/v1/recipeblog/recipe/123
-
Update Recipe by ID Endpoint:
curl -X PUT -H "Content-Type: application/json" -d '{ "title": "Updated Cake", "description": "An even better cake recipe", "categories": ["Dessert", "Baking", "Special"], "ingredients": ["Flour", "Sugar", "Eggs", "Butter", "Vanilla Extract"] }' http://localhost:8080/api/v1/recipeblog/{id}
Replace
{id}
with the actualrecipeId
you want to update. For example, if therecipeId
is 123, the request will be:curl -X PUT -H "Content-Type: application/json" -d '{ "title": "Updated Cake", "description": "An even better cake recipe", "categories": ["Dessert", "Baking", "Special"], "ingredients": ["Flour", "Sugar", "Eggs", "Butter", "Vanilla Extract"] }' http://localhost:8080/api/v1/recipeblog/123
-
Delete Recipe by ID Endpoint:
curl -X DELETE http://localhost:8080/api/v1/recipeblog/{id}
Replace
{id}
with the actualrecipeId
you want to delete. For example, if therecipeId
is 123, the request will be:curl -X DELETE http://localhost:8080/api/v1/recipeblog/123
-
Save or Update Ingredient to a Recipe Endpoint:
curl -X POST -H "Content-Type: application/json" -d '{ "name": "Sugar", "quantity": "2 cups", "recipe": { "id": 1 } }' http://localhost:8080/api/v1/recipeblog/ingredients/create-or-save-ingredient
-
Retrieve Ingredients from a Recipe Endpoint:
curl http://localhost:8080/api/v1/recipeblog/ingredients/recipe/{id}
Replace
{id}
with the actualrecipeId
for which you want to retrieve ingredients. For example, if therecipeId
is 1, the request will be:curl http://localhost:8080/api/v1/recipeblog/ingredients/recipe/1
-
Find Ingredient by ID Endpoint:
curl http://localhost:8080/api/v1/recipeblog/ingredients/ingredient/{id}
Replace
{id}
with the actualingredientId
you want to retrieve. For example, if theingredientId
is 123, the request will be:curl http://localhost:8080/api/v1/recipeblog/ingredients/ingredient/123
-
Delete Ingredient by ID Endpoint:
curl -X DELETE http://localhost:8080/api/v1/recipeblog/ingredients/{id}
Replace
{id}
with the actualingredientId
you want to delete. For example, if theingredientId
is 123, the request will be:curl -X DELETE http://localhost:8080/api/v1/recipeblog/ingredients/123
-
Create Category Endpoint:
curl -X POST -H "Content-Type: application/json" -d '{ "name": "Dessert" }' http://localhost:8080/api/v1/recipeblog/categories/create-category
-
Update Category Endpoint:
curl -X PUT -H "Content-Type: application/json" -d '{ "name": "Updated Dessert" }' http://localhost:8080/api/v1/recipeblog/categories/{id}
Replace
{id}
with the actualcategoryId
you want to update. For example, if thecategoryId
is 1, the request will be:curl -X PUT -H "Content-Type: application/json" -d '{ "name": "Updated Dessert" }' http://localhost:8080/api/v1/recipeblog/categories/1
-
Get List of All Categories Endpoint:
curl http://localhost:8080/api/v1/recipeblog/categories
-
Get Categories According to Recipe Endpoint:
curl http://localhost:8080/api/v1/recipeblog/categories/recipe/{id}
Replace
{id}
with the actualrecipeId
for which you want to retrieve categories. For example, if therecipeId
is 1, the request will be:curl http://localhost:8080/api/v1/recipeblog/categories/recipe/1
-
Retrieve Category by ID Endpoint:
curl http://localhost:8080/api/v1/recipeblog/categories/{id}
Replace
{id}
with the actualcategoryId
you want to retrieve. For example, if thecategoryId
is 123, the request will be:curl http://localhost:8080/api/v1/recipeblog/categories/123
-
Delete Category by ID Endpoint:
curl -X DELETE http://localhost:8080/api/v1/recipeblog/categories/{id}
Replace
{id}
with the actualcategoryId
you want to delete. For example, if thecategoryId
is 123, the request will be:curl -X DELETE http://localhost:8080/api/v1/recipeblog/categories/123
Make sure to fill in the necessary JSON data (if required) for the
POST
andPUT
requests.