Last active
March 23, 2017 02:31
-
-
Save EITANINOMIYA/2605454cf51eba344bb4d380815d8185 to your computer and use it in GitHub Desktop.
【Lambda】マッピングの書き方
This file contains hidden or 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
/*################################################# | |
# lambdaのnodejsで接続元のIPを取得出来るようにするマッピングと | |
# GETパラメータを取得出来るようにするマッピングの書き方 | |
# | |
# nodejsでのサンプルコードも | |
#################################################*/ | |
// mapping定義ファイル | |
{ | |
"sourceIp" : "$context.identity.sourceIp", // 接続元のIP | |
"querystring" : "$input.params().querystring", | |
"query" : { // GETパラメータ。 | |
#foreach($param in $input.params().querystring.keySet()) | |
"$param" : "$util.escapeJavaScript($input.params().querystring.get($param))" #if($foreach.hasNext),#end | |
#end | |
} | |
} | |
// nodejs | |
exports.handler = function(event, context, callback) { | |
var query = event.query; | |
console.log(query.hoge); // http://xxxxx.com/?hoge=123, 123が表示される | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment