The Hero object has the following structure:
{
id: primitive.ObjectID,
name: String
}
The API handles the following HTTP requests:
METHOD |
PATH |
PAYLOAD |
RESPONSE |
DESCRIPTION |
GET |
/hero |
|
[Hero] |
Gets all heroes |
POST |
/hero |
{ name: String } |
Hero |
Add a new hero |
DELETE |
/hero/{id} |
|
Hero |
Removes a hero |
GET |
/hero/{id} |
|
Hero |
Gets a specific hero |
PUT |
/hero |
{ id: primitive.ObjectID, name: String } |
Hero |
Changes the hero's name |
Status code |
Occasion |
200 |
Every situation |
Status code |
Occasion |
400 |
Wrong fields, wrong types or empty name |
500 |
Internal Server Error (e.g. Database error) |
200 |
Otherwise |
Status code |
Occasion |
400 |
Invalid id (empty or not an integer) |
404 |
Hero not found |
500 |
Internal Server Error (e.g. Database error) |
200 |
Otherwise |
Status code |
Occasion |
400 |
Invalid id (empty or not an integer) |
404 |
Hero not found |
500 |
Internal Server Error (e.g. Database error) |
200 |
Otherwise |
Status code |
Occasion |
400 |
Wrong fields, wrong types or empty name |
404 |
Hero not found |
500 |
Internal Server Error (e.g. Database error) |
200 |
Otherwise |