-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Geolocation using API Gateway | ||
|
||
API Gateway requests go through CloudFront, and they will contain a few useful analytic headers, including the geo-location country | ||
where the request originated. This is a simple example that shows how to read out the country header and use it in your API. | ||
|
||
## Get started | ||
|
||
* run `npm init` to install the dependencies | ||
* run `npm run create` to deploy this project to AWS | ||
* grab the URL printed as the result, and GET it using CURL or paste into a browser | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/*global module, require */ | ||
var API = require('claudia-api-builder'), | ||
api = new API(); | ||
|
||
api.get('/', function (request) { | ||
'use strict'; | ||
return { | ||
IP: request.context.sourceIp, | ||
Country: request.headers['CloudFront-Viewer-Country'] | ||
}; | ||
}); | ||
|
||
module.exports = api; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "api-gw-geolocation", | ||
"version": "1.0.0", | ||
"description": "A simple demonstration of built-in geolocation service with API Gateway", | ||
"main": "index.js", | ||
"scripts": { | ||
"create": "claudia create --region us-east-1 --api-module api", | ||
"update": "claudia update" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "MIT", | ||
"dependencies": { | ||
"claudia-api-builder": "^2.3.1" | ||
}, | ||
"devDependencies": { | ||
"claudia": "^2.5.0" | ||
} | ||
} |