Catalog service repo - this is part of the larger ACME fitness application
@sha256:de12574a7e9d62fe9e3f466a6687d78428f50c5143b49b7485947101858c2ae3/details?tab=info">
A catalog service, because what is a shop without a catalog to show off our awesome red pants?
The Catalog service is part of the ACME Fitness Shop. The goal of this specific service is to register and serve the catalog of items sold by the shop.
There are different dependencies based on whether you want to run a built container, or build a new one.
Use this command to pull the latest tagged version of the shipping service:
docker pull gcr.io/vmwarecloudadvocacy/amceshop-catalog:stable
To build a docker container, run docker build . -t vmwarecloudadvocacy/acmeshop-catalog:<tag>
.
The images are tagged with:
<Major>.<Minor>.<Bug>
, for example 1.1.0
stable
: denotes the currently recommended image appropriate for most situationslatest
: denotes the most recently pushed image. It may not be appropriate for all use casesTo build the app as a stand-alone executable, run go build
.
The catalog service, either running inside a Docker container or as a stand-alone app, relies on the below environment variables:
0.0.0.0
)8082
)v1
, must start with the letter v)The Docker image is based on the Bitnami MiniDeb container. Use this commands to run the latest stable version of the payment service with all available parameters:
# Run the MongoDB container
docker run -d -p 27017:27017 --name mgo -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=secret -e MONGO_INITDB_DATABASE=acmefit gcr.io/vmwarecloudadvocacy/acmeshop-catalog-db
# Run the user service
docker run -d -e CATALOG_HOST=0.0.0.0 -e CATALOG_PORT=8082 -e CATALOG_VERSION=v1 -e CATALOG_DB_USERNAME=mongoadmin -e CATALOG_DB_PASSWORD=secret -e CATALOG_DB_HOST=0.0.0.0 -e USERS_HOST=0.0.0.0 -e USERS_PORT=8083 -p 8082:8082 gcr.io/vmwarecloudadvocacy/acmeshop-catalog:stable
GET /products
Returns a list of all catalog items
curl --request GET \
--url http://localhost:8082/products
{
"data": [
{
"id": "5c61f497e5fdadefe84ff9b9",
"name": "Yoga Mat",
"shortDescription": "Limited Edition Mat",
"description": "Limited edition yoga mat",
"imageUrl1": "/static/images/yogamat_square.jpg",
"imageUrl2": "/static/images/yogamat_thumb2.jpg",
"imageUrl3": "/static/images/yogamat_thumb3.jpg",
"price": 62.5,
"tags": [
"mat"
]
},
{
"id": "5c61f497e5fdadefe84ff9ba",
"name": "Water Bottle",
"shortDescription": "Best water bottle ever",
"description": "For all those athletes out there, a perfect bottle to enrich you",
"imageUrl1": "/static/images/bottle_square.jpg",
"imageUrl2": "/static/images/bottle_thumb2.jpg",
"imageUrl3": "/static/images/bottle_thumb3.jpg",
"price": 34.99,
"tags": [
"bottle"
]
}
]}
POST /product
Create a new product item
curl --request POST \
--url http://localhost:8082/products \
--header 'content-type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data ' {
"name": "Tracker",
"shortDescription": "Limited Edition Tracker",
"description": "Limited edition Tracker with longer description",
"imageurl1": "/static/images/tracker_square.jpg",
"imageurl2": "/static/images/tracker_thumb2.jpg",
"imageurl3": "/static/images/tracker_thumb3.jpg",
"price": 149.99,
"tags": [
"tracker"
]
}'
The call to this service needs a valid product object
{
"name": "Tracker",
"shortDescription": "Limited Edition Tracker",
"description": "Limited edition Tracker with longer description",
"imageurl1": "/static/images/tracker_square.jpg",
"imageurl2": "/static/images/tracker_thumb2.jpg",
"imageurl3": "/static/images/tracker_thumb3.jpg",
"price": 149.99,
"tags": [
"tracker"
]
}
When the product is created successfully, an HTTP/201 message is returned
{
"message": "Product created successfully!",
"resourceId": {
"id": "5c61f8f81d41c8e94ecaf25f",
"name": "Tracker",
"shortDescription": "Limited Edition Tracker",
"description": "Limited edition Tracker with longer description",
"imageUrl1": "/static/images/tracker_square.jpg",
"imageUrl2": "/static/images/tracker_thumb2.jpg",
"imageUrl3": "/static/images/tracker_thumb3.jpg",
"price": 149.99,
"tags": [
"tracker"
]
},
"status": 201
}
GET /products/:id
Returns details about a specific product id
curl --request GET \
--url http://localhost:8082/products/5c61f497e5fdadefe84ff9b9
{
"data": {
"id": "5c61f497e5fdadefe84ff9b9",
"name": "Yoga Mat",
"shortDescription": "Limited Edition Mat",
"description": "Limited edition yoga mat",
"imageUrl1": "/static/images/yogamat_square.jpg",
"imageUrl2": "/static/images/yogamat_square.jpg",
"imageUrl3": "/static/images/bottle_square.jpg",
"price": 62.5,
"tags": [
"mat"
]
},
"status": 200
}
GET /static/images/:imageName
Retrieve specific image
GET /liveness
The liveness operation returns the current status and version of the server
curl --request GET \
--url http://localhost:8082/liveness
{
"data": {
"version": "v1",
"servicename": "catalog",
},
"status": 200
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
See the LICENSE file in the repository