by

Sending all HTTP parameters in API Gateway

Here’s an API Gateway mapping template to send all HTTP path, query string, and header parameters to your backend integration (i.e. Lambda function).

#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
            #end
        }
        #if($foreach.hasNext),#end
    #end
    }
}

will produce something like:

{
   "body-json":"{}",
   "params":{
      "path":{
         "pathParamName1":"pathParamValue1",
         "pathParamName2":"pathParamValue2",
         "pathParamName3":"pathParamValue3"
      },
      "querystring":{
         "queryParamName1":"queryParamValue1",
         "queryParamName2":"queryParamValue2",
         "queryParamName3":"queryParamValue3"
      },
      "header":{
         "headerParamName1":"headerParamValue1",
         "headerParamName2":"headerParamValue2",
         "headerParamName3":"headerParamValue3"
      }
   }
}

The parameters can then be accessed in your Lambda function, i.e.

exports.myHandler = function(event, context) {
   console.log("pathParamName1 = " + event.params.path.pathParamName1);
   context.succeed("");
}

Here’s a Gist with the example.

Cheers,
Ryan

Write a Comment

Comment

  1. That wouldn’t work currently as non-alpha characters aren’t supported in parameter names in API Gateway. I’ve seen many conventions for query string arrays/maps but there’s no accepted standard defined in RFC3986, so API Gateway typically doesn’t support these. I’d recommend following up on the API Gateway forums with your specific use case.

    Cheers,
    Ryan

Webmentions

  • alka seltzer viagra January 6, 2016

    alka seltzer viagra

    alka seltzer viagra

  • cialis alternative January 6, 2016

    cialis alternative

    cialis alternative

  • viagra commercial lady blue dress January 6, 2016

    viagra commercial lady blue dress

    viagra commercial lady blue dress

  • cialis usage instructions January 6, 2016

    cialis usage instructions

    cialis usage instructions

  • cialis in action January 6, 2016

    cialis in action

    cialis in action

  • sildenafil viagra January 6, 2016

    sildenafil viagra

    sildenafil viagra

  • cialis 10mg January 6, 2016

    cialis 10mg

    cialis 10mg

  • viagra sales January 6, 2016

    viagra sales

    viagra sales

  • viagra online cheap January 6, 2016

    viagra online cheap

    viagra online cheap

  • cialis information January 6, 2016

    cialis information

    cialis information

  • what are citalopram January 6, 2016

    what are citalopram

    what are citalopram

  • celebrex arrhythmia January 6, 2016

    celebrex arrhythmia

    celebrex arrhythmia

  • using coreg and cialis January 6, 2016

    using coreg and cialis

    using coreg and cialis

  • forum buspar January 6, 2016

    forum buspar

    forum buspar

  • what is buspar 10 mg January 6, 2016

    what is buspar 10 mg

    what is buspar 10 mg

  • bupropion hcl er sr January 6, 2016

    bupropion hcl er sr

    bupropion hcl er sr

  • intrathecal baclofen pump for spasticity January 6, 2016

    intrathecal baclofen pump for spasticity

    intrathecal baclofen pump for spasticity

  • icd 10 code for removal of baclofen pump January 6, 2016

    icd 10 code for removal of baclofen pump

    icd 10 code for removal of baclofen pump

  • azithromycin and bronchitis January 6, 2016

    azithromycin and bronchitis

    azithromycin and bronchitis

  • atorvastatin labs January 6, 2016

    atorvastatin labs

    atorvastatin labs

  • abilify lawsuit January 6, 2016

    abilify lawsuit

    abilify lawsuit

  • what is amoxicillin used for January 6, 2016

    what is amoxicillin used for

    what is amoxicillin used for

  • amlodipine interactions January 6, 2016

    amlodipine interactions

    amlodipine interactions

  • amitriptyline buspar porr actions January 6, 2016

    amitriptyline buspar porr actions

    amitriptyline buspar porr actions

  • amiodarone hydrochloride tablets January 6, 2016

    amiodarone hydrochloride tablets

    amiodarone hydrochloride tablets

  • allopurinol risks January 6, 2016

    allopurinol risks

    allopurinol risks

  • recreational abilify January 6, 2016

    recreational abilify

    recreational abilify

  • tizanidine pseudoephedrine January 6, 2016

    tizanidine pseudoephedrine

    tizanidine pseudoephedrine

  • oxybutynin pill picture January 6, 2016

    oxybutynin pill picture

    oxybutynin pill picture

  • ciprofloxacin side effects January 6, 2016

    ciprofloxacin side effects

    ciprofloxacin side effects

  • can you take cephalexin for strep throat January 6, 2016

    can you take cephalexin for strep throat

    can you take cephalexin for strep throat

  • coupons for viagra January 6, 2016

    coupons for viagra

    coupons for viagra

  • cialis tadalafil January 6, 2016

    cialis tadalafil

    cialis tadalafil

  • is viagra safe January 6, 2016

    is viagra safe

    is viagra safe

  • which is stronger cefdinir or augmentin January 6, 2016

    which is stronger cefdinir or augmentin

    which is stronger cefdinir or augmentin

  • viagra generico January 6, 2016

    viagra generico

    viagra generico

  • levitra January 6, 2016

    levitra

    levitra

  • viagra sample pack January 6, 2016

    viagra sample pack

    viagra sample pack

  • incest viagra January 6, 2016

    incest viagra

    incest viagra

  • brother takes viagra January 6, 2016

    brother takes viagra

    brother takes viagra

  • atorvastatin 30 mg January 6, 2016

    atorvastatin 30 mg

    atorvastatin 30 mg

  • reddit viagra January 6, 2016

    reddit viagra

    reddit viagra

  • what is cialis January 6, 2016

    what is cialis

    what is cialis

  • viagra in action January 6, 2016

    viagra in action

    viagra in action

  • generic viagra online January 6, 2016

    generic viagra online

    generic viagra online

  • revatio vs viagra January 6, 2016

    revatio vs viagra

    revatio vs viagra

  • liquid viagra January 6, 2016

    liquid viagra

    liquid viagra

  • buy levitra January 6, 2016

    buy levitra

    buy levitra

  • otc viagra January 6, 2016

    otc viagra

    otc viagra

  • taking viagra January 6, 2016

    taking viagra

    taking viagra

  • viagra alternative January 6, 2016

    viagra alternative

    viagra alternative

  • cialis 5 mg January 6, 2016

    cialis 5 mg

    cialis 5 mg

  • canada viagra January 6, 2016

    canada viagra

    canada viagra

  • viagra dosage January 6, 2016

    viagra dosage

    viagra dosage

  • levitra 10mg January 6, 2016

    levitra 10mg

    levitra 10mg

  • tadalafil 20 mg canadian drug stores January 6, 2016

    tadalafil 20mg

    cialis tadalafil reviews add.asp – cialis pills online reply #4 on – cialis 10mg price announcements

  • generic viagra January 6, 2016

    viagra for sale

    viagra bivirkninger – viagra commercials settings – viagra risks

  • viagra 100mg January 6, 2016

    viagra for sale

    viagra for women does it work jump to – trackback skriv en kommentar viagra – viagra dose medications contact info

  • walmart cialis January 6, 2016

    cialis at walmart

    brand cialis – cialis commercial last post – cialis dosage forum newbie

  • levitra coupon January 6, 2016

    levitra vs viagra

    natural remedies for ed – dosage for levitra – levitra 5 mg