Starbucks REST API
- Type: REST Web Service
- Tools: Spring MVC + Spring Security + Hibernate + MySQL
HTTP Method | Path | Description |
---|---|---|
GET | /api/coffee | Get a list of Hot Coffees (via Starbucks menu) |
GET | /api/coffee/{id} | Get a Hot Coffee by its ID |
POST | /api/coffee | Add a new Hot Coffee to menu |
PUT | /api/coffee | Update a Hot Coffee in menu |
DELETE | /api/coffee/{id} | Delete a Hot Coffee by its ID |
Tables:
- Coffee (contains info about Starbucks Hot Coffees)
- Users (contains users of the API)
- Authorities (contains roles of the API users)
There are 3 types of roles:
- USER can perform
GET
operations - EDITOR can perform
PUT
operation - ADMIN can perform
POST
andDELETE
operations
{
"id": 18,
"name": "Caffè Latte",
"type": "Lattes",
"calories": 190,
"description": "Our dark, rich espresso balanced with steamed milk and a light layer of foam. A perfect milk-forward warm-up."
}
{
"name": "Espresso Con Panna",
"type": "Espresso Shots",
"calories": 35,
"description": "Espresso meets a dollop of whipped cream to enhance the rich and caramelly flavors of a straight-up shot."
}
Result:
{
"id": 9,
"name": "Espresso Con Panna",
"type": "Espresso Shots",
"calories": 35,
"description": "Espresso meets a dollop of whipped cream to enhance the rich and caramelly flavors of a straight-up shot."
}
Deleted Hot Coffee id is 18
This service handles exception for situation when user make a request with non-existent ID:
{
"status": "NOT_FOUND",
"code": "404",
"message": "No coffee with this ID: 90",
"timeStamp": "2021-02-12 01:38:21"
}