Skip to content

Instantly share code, notes, and snippets.

Ryan Green rpgreen

Block or report user

Report or block rpgreen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rpgreen
rpgreen / gist:5cd3d5c872781335a5d3
Last active May 14, 2018
An API Gateway mapping template to output all HTTP parameters in the JSON body
View gist:5cd3d5c872781335a5d3
#set($allParams = $input.params())
{
"body-json" : "$input.json('$')",
"params" : {
#foreach($type in $allParams.keySet())
#set($params = $allParams.get($type))
"$type" : {
#foreach($paramName in $params.keySet())
"$paramName" : "$util.escapeJavaScript($params.get($paramName))"
#if($foreach.hasNext),#end
@rpgreen
rpgreen / master.vm
Created Feb 23, 2016
API Gateway "Send Everything" Mapping Template
View master.vm
## API Gateway "Send Everything" Mapping Template - Ryan Green - ryang@ryang.ca
## See http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
#set($allParams = $input.params())
{
"body-json" : "$input.json('$')",
"params" : {
#foreach($type in $allParams.keySet())
#set($params = $allParams.get($type))
"$type" : {
#foreach($paramName in $params.keySet())
@rpgreen
rpgreen / Latency.java
Last active Dec 10, 2018
A simple script to measure API Gateway endpoint latency. Requires Apache HttpComponents
View Latency.java
@Test
public void testPerf() throws IOException {
final HttpGet request = new HttpGet("https://[API-ID].execute-api.[REGION].amazonaws.com/[STAGE]/[PATH]");
final int numRequests = 10000;
final int[] histogram = new int[100];
final List<Integer> latencies = new ArrayList<>();
final CloseableHttpClient client = HttpClients.createDefault();
for (int i = 0; i < numRequests; i++) {
@rpgreen
rpgreen / gist:c127aa4ebbcaa9026be7
Last active Sep 1, 2019
Swagger file demonstrating two ways to achieve HTTP redirects using API Gateway and Lambda
View gist:c127aa4ebbcaa9026be7
---
swagger: "2.0"
basePath: "/test"
schemes:
- "https"
paths:
/lambdaredirect-default:
get:
produces:
- "application/json"
You can’t perform that action at this time.