[go: nahoru, domu]

Skip to content

Commit

Permalink
improve readmes
Browse files Browse the repository at this point in the history
  • Loading branch information
csplinter committed Jun 11, 2020
1 parent 40532d8 commit fad673c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 39 deletions.
27 changes: 11 additions & 16 deletions microservice-spring-boot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,39 +45,34 @@ kubectl -n spring-boot-service logs -f <pod-name>

### Access the endpoints

Get the URL of the NodePort of the service
Forward the local port to that of the service
```
minikube -n spring-boot-service service spring-boot-service --url
```
You will see output that looks similar to the following
```
🏃 Starting tunnel for service spring-boot-service.
|---------------------|---------------------|-------------|------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|---------------------|---------------------|-------------|------------------------|
| spring-boot-service | spring-boot-service | | http://127.0.0.1:59165 |
|---------------------|---------------------|-------------|------------------------|
kubectl -n spring-boot-service get pods
kubectl -n spring-boot-service port-forward <pod-name> 8083:8083
```

Test the endpoints with curl

Add products
```
curl -X POST -H "Content-Type: application/json" -d '{"name": "mobile", "id":"123e4567-e89b-12d3-a456-556642440000", "description":"iPhone", "price":"500.00"}' <replace-with-url>/api/products/add
curl -X POST -H "Content-Type: application/json" -d '{"name": "mobile", "id":"123e4567-e89b-12d3-a456-556642440001", "description":"Android", "price":"600.00"}' <replace-with-url>/api/products/add
curl -X POST -H "Content-Type: application/json" \
-d '{"name": "mobile", "id":"123e4567-e89b-12d3-a456-556642440000", "description":"iPhone", "price":"500.00"}' http://localhost:8083/api/products/add
curl -X POST -H "Content-Type: application/json" \
-d '{"name": "mobile", "id":"123e4567-e89b-12d3-a456-556642440001", "description":"Android", "price":"600.00"}' http://localhost:8083/api/products/add
```

Get products with name = mobile
```
curl <replace-with-url>/api/products/search/mobile
curl http://localhost:8083/api/products/search/mobile
```

Get products with name = mobile and id = 123e4567-e89b-12d3-a456-556642440001
```
curl <replace-with-url>/api/products/search/mobile/123e4567-e89b-12d3-a456-556642440001
curl http://localhost:8083/api/products/search/mobile/123e4567-e89b-12d3-a456-556642440001
```

Delete product with name = mobile and id = 123e4567-e89b-12d3-a456-556642440001
```
curl -X DELETE <replace-with-url>/api/products/delete/mobile/123e4567-e89b-12d3-a456-556642440001
curl -X DELETE http://localhost:8083/api/products/delete/mobile/123e4567-e89b-12d3-a456-556642440001
```
40 changes: 17 additions & 23 deletions microservice-spring-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,51 +45,45 @@ kubectl -n spring-data-service logs -f <pod-name>

### Access the endpoints

Get the URL of the NodePort of the service
Forward the local port to that of the service
```
minikube -n spring-data-service service spring-data-service --url
```
You will see output that looks similar to the following
```
🏃 Starting tunnel for service spring-data-service.
|---------------------|---------------------|-------------|------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|---------------------|---------------------|-------------|------------------------|
| spring-data-service | spring-data-service | | http://127.0.0.1:59165 |
|---------------------|---------------------|-------------|------------------------|
kubectl -n spring-data-service get pods
kubectl -n spring-data-service port-forward <pod-name> 8081:8081
```

Test the endpoints with curl

Add an order
Add orders
```
curl -H "Content-Type: application/json" -d '{"key": {"orderId":"123e4567-e89b-12d3-a456-556642440000", "productId":"123e4567-e89b-12d3-a456-556642440000"}, "productName":"iPhone", "productPrice":"500.00", "productQuantity":1, "addedToOrderTimestamp": "2020-04-12T11:21:59.001+0000"}' <replace-with-url>/api/orders/add
curl -H "Content-Type: application/json" -d '{"key": {"orderId":"123e4567-e89b-12d3-a456-556642440000", "productId":"123e4567-e89b-12d3-a456-556642440001"}, "productName":"Android", "productPrice":"600.00", "productQuantity":1, "addedToOrderTimestamp": "2020-04-12T11:22:59.001+0000"}' <replace-with-url>/api/orders/add
curl -H "Content-Type: application/json" \
-d '{"key": {"orderId":"123e4567-e89b-12d3-a456-556642440000", "productId":"123e4567-e89b-12d3-a456-556642440000"}, "productName":"iPhone", "productPrice":"500.00", "productQuantity":1, "addedToOrderTimestamp": "2020-04-12T11:21:59.001+0000"}' http://localhost:8081/api/orders/add
curl -H "Content-Type: application/json" \
-d '{"key": {"orderId":"123e4567-e89b-12d3-a456-556642440000", "productId":"123e4567-e89b-12d3-a456-556642440001"}, "productName":"Android", "productPrice":"600.00", "productQuantity":1, "addedToOrderTimestamp": "2020-04-12T11:22:59.001+0000"}' http://localhost:8081/api/orders/add
```

Get orders with order_id = 123e4567-e89b-12d3-a456-556642440000
```
curl <replace-with-url>/api/orders/search/order-by-id?orderId=123e4567-e89b-12d3-a456-556642440000
curl http://localhost:8081/api/orders/search/order-by-id?orderId=123e4567-e89b-12d3-a456-556642440000
```

Get order with order_id = 123e4567-e89b-12d3-a456-556642440000 and product_id = 123e4567-e89b-12d3-a456-556642440000
```
curl "<replace-with-url>/api/orders/search/order-by-product-id?orderId=123e4567-e89b-12d3-a456-556642440000&productId=123e4567-e89b-12d3-a456-556642440000"
```
Get only the product name and price of order_id = 123e4567-e89b-12d3-a456-556642440000
```
curl <replace-with-url>/api/orders/search/name-and-price-only?orderId=123e4567-e89b-12d3-a456-556642440000
curl "http://localhost:8081/api/orders/search/order-by-product-id?orderId=123e4567-e89b-12d3-a456-556642440000&productId=123e4567-e89b-12d3-a456-556642440000"
```

Shows how to use a projection with Spring Data REST
```
curl "<replace-with-url>/api/orders/search/name-and-price-only?orderId=123e4567-e89b-12d3-a456-556642440000&projection=product-name-and-price"
curl http://localhost:8081/api/orders/search/name-and-price-only?orderId=123e4567-e89b-12d3-a456-556642440000
curl "http://localhost:8081/api/orders/search/name-and-price-only?orderId=123e4567-e89b-12d3-a456-556642440000&projection=product-name-and-price"
```

Delete order with order_id = 123e4567-e89b-12d3-a456-556642440000 and product_id = 123e4567-e89b-12d3-a456-556642440000
```
curl -X DELETE "<replace-with-url>/api/orders/delete/product-from-order?orderId=123e4567-e89b-12d3-a456-556642440000&productId=123e4567-e89b-12d3-a456-556642440000"
curl -X DELETE "http://localhost:8081/api/orders/delete/product-from-order?orderId=123e4567-e89b-12d3-a456-556642440000&productId=123e4567-e89b-12d3-a456-556642440000"
```

Delete order with order_id = 123e4567-e89b-12d3-a456-556642440000
```
curl -X DELETE "<replace-with-url>/api/orders/delete/order?orderId=123e4567-e89b-12d3-a456-556642440000"```
curl -X DELETE "http://localhost:8081/api/orders/delete/order?orderId=123e4567-e89b-12d3-a456-556642440000"
```

0 comments on commit fad673c

Please sign in to comment.