This is a dead simple server implementing RESTful API. Please find below all methods description and examples. All dependencies are stored in Godep vendor folders. By default it's running at 3000 port, but you can change it using -port parameter.
curl -X POST -H "Content-Type: application/json; charset=utf-8" -d '{"Name":"New Product", "Description": "Should be cool", "Price": 5.0, "Tags":["new", "cool"]}' "http://localhost:3000/products"
Content-Type: application/json; charset=utf-8
{
"Name": "New Product",
"Description": "Should be cool",
"Price": 5.0,
"Tags": ["new", "cool"]
}
content-type: application/json; charset=utf-8
status: 200 OK
{
"ID": 1
}
curl -X PUT -H "Content-Type: application/json; charset=utf-8" -d '{"Name":"New Product Updated", "Description": "Should be cool", "Price": 15.0, "Tags":["new", "cool", "updated"]}' "http://localhost:3000/products/1"
Content-Type: application/json; charset=utf-8
{
"Name": "New Product Updated",
"Description": "Should be cool",
"Price": 15.0,
"Tags": ["new", "cool", "updated"]
}
content-type: application/json; charset=utf-8
status: 200 OK
curl -X GET -H "Content-Type: application/json; charset=utf-8" "http://localhost:3000/products"
Content-Type: application/json; charset=utf-8
content-type: application/json; charset=utf-8
status: 200 OK
{
[
{
"ID": 1,
"Name": "New Product Updated",
"Description": "Should be cool",
"Price": 15,
"Tags": ["new", "cool", "updated"]
}
]
}
curl -X PUT -H "Content-Type: application/json; charset=utf-8" -d '{"EUR": 20.15, "RUR":100.75}' "http://localhost:3000/products/1/prices"
Content-Type: application/json; charset=utf-8
{
"EUR": 20.15,
"RUR": 1000.75,
}
content-type: application/json; charset=utf-8
status: 200 OK
curl -X GET -H "Content-Type: application/json; charset=utf-8" "http://localhost:3000/products/1"
Content-Type: application/json; charset=utf-8
content-type: application/json; charset=utf-8
status: 200 OK
{
"ID": 1,
"Name": "New Product Updated",
"Description": "Should be cool",
"Price": 15,
"Tags": ["new", "cool", "updated"],
"Prices":{"EUR": 20.15, "RUR": 100.75}
}
curl -X DELETE -H "Content-Type: application/json; charset=utf-8" "http://localhost:3000/products/1"
Content-Type: application/json; charset=utf-8
content-type: application/json; charset=utf-8
status: 200 OK
- 200 - OK, success
- 400 - Bad request with wrong product data
- 404 - Product is not found
- 500 - Internal server error