Skip to content

Instantly share code, notes, and snippets.

View allanchua101's full-sized avatar
👹
Coding and grinding

Allan Chua allanchua101

👹
Coding and grinding
View GitHub Profile
docker images demo/*
REPOSITORY TAG IMAGE ID CREATED SIZE
demo/gateway-api latest 00a9bb7d6e41 6 minutes ago 298MB
demo/catalog-api latest 43205442eae5 8 minutes ago 294MB
demo/ledger-api latest c385cc51dfed 10 minutes ago 298MB
demo/authentication-api latest 562df01136a4 12 minutes ago 294MB
@allanchua101
allanchua101 / Containerize Gateway.sh
Created September 16, 2018 13:18
Command for containerizing the gateway.
docker build -t demo/authentication-api ./Authentication/
docker build -t demo/ledger-api ./Ledger/
docker build -t demo/catalog-api ./Catalog/
docker build -t demo/gateway-api ./Gateway/
@allanchua101
allanchua101 / Dockerfile
Last active September 16, 2018 14:53
Basic Dockerfile for ASP.net core apps
# Pulls a build image for compiling your
# application inside a container.
FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app
# Copy csproj into the docker container
COPY *.csproj ./
# Downloads the nuget packages
# required by your application into
@allanchua101
allanchua101 / Rate limiting fresh response.json
Created September 12, 2018 14:29
Response from simple API
[{
"productID":"ef29fc61-abcc-4ac1-9c8c-e5e17b266868",
"userID":"539bf338-e5de-4fc4-ac65-4a91324d8111",
"priceAtPointInTime":36.0,
"occuredAt":"2018-05-05T00:00:00",
"quantity":5.0,
"total":180.0
},{
"productID":"ef29fc61-abcc-4ac1-9c8c-e5e17b266868",
"userID":"539bf338-e5de-4fc4-ac65-4a91324d8111",
@allanchua101
allanchua101 / Global Rate Limiting.json
Created September 9, 2018 10:28
Configuration used for implementing global rate limiting strategies.
"GlobalConfiguration": {
"BaseUrl": "http://localhost:52793",
"RateLimitOptions": {
"DisableRateLimitHeaders": false,
"QuotaExceededMessage": "Customize Tips!",
"HttpStatusCode": 999,
"ClientIdHeader": "Test"
}
}
@allanchua101
allanchua101 / Rate Limiting.json
Created September 9, 2018 10:09
Rate limiting demo for Ocelot Framework
{
"DownstreamPathTemplate": "/api/transaction/getbyuserid/{id}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 52790
}
],
"UpstreamPathTemplate": "/api/transaction/getbyuserid/{id}",
@allanchua101
allanchua101 / Aggregated Response.json
Created September 4, 2018 15:25
Aggregated user transaction response.
{"user-profile":{
"userId":"539bf338-e5de-4fc4-ac65-4a91324d8111",
"firstName":"Allan",
"lastName":"Chua"
},"user-transactions":[{
"productID":"ef29fc61-abcc-4ac1-9c8c-e5e17b266868",
"userID":"539bf338-e5de-4fc4-ac65-4a91324d8111",
"priceAtPointInTime":36.0,
"occuredAt":"2018-05-05T00:00:00",
"quantity":5.0,
@allanchua101
allanchua101 / UserController.cs
Created September 4, 2018 13:57
Endpoint for retrieving user profiles by ID.
[HttpGet("/api/user/getbyid/{id}")]
public User GetByID(Guid? id)
{
return users.FirstOrDefault(u => u.UserId == id);
}
@allanchua101
allanchua101 / TransactionsController.cs
Last active September 4, 2018 13:56
New endpoint for retrieving user transactions
[HttpGet("/api/transaction/getbyuserid/{id}")]
public List<Transaction> GetByUserID(Guid? id)
{
return transactions.Where(t => t.UserID == id)
.ToList();
}
@allanchua101
allanchua101 / Aggregate Definition.json
Created September 3, 2018 15:55
Aggregating new routes
"Aggregates": [
{
"ReRouteKeys": [
"user-transactions",
"user-profile"
],
"UpstreamPathTemplate": "/api/user-transactions/{id}"
}
]