Code Monkey home page Code Monkey logo

Comments (3)

jamesvillarrubia avatar jamesvillarrubia commented on July 21, 2024

I just submitted a PR for this. #67 Hopefully it'll roll out soon. In the meantime, you can fiddle with a field overwrite ahead of the handler call in AWS. The queryStringParameters field in the event should be a subset of the multiValueQueryStringParameters field, so you can || them or just overwrite the queryStringParameters directly.

//index.js

const serverless = require('serverless-http')
const app = require('./app')

let server = serverless(app, {
  callbackWaitsForEmptyEventLoop: false,
  request: function (request, event, context) {
    // ...
  },
  response: function (response, event, context) {
   // ...
  }
})
app.setup(server)

module.exports = {
  handler: async (event, context) => {
    event.queryStingParameters = event.multiValueQueryStringParameters
    return server(event, context)
  }
}

I have a fork with functioning code for AWS Lambda / node at least here: https://github.com/jamesvillarrubia/serverless-http. Feel free to npm install it directly.

from serverless-http.

kbrownlees avatar kbrownlees commented on July 21, 2024

Thanks @jamesvillarrubia for pointing me in the right direction.

Note for anyone trying to do this (for application load balancer at least) you need to convert the querystrings / headers on the way in and the headers on the way out.

eg:

module.exports = {
    handler: (event, context) =>
        event = util.serverlessTransformMultiValuesIncoming(event)
        event = util.serverlessCleanQueryStringParameters(event)

        server(event, context)
        .then (res) =>
            res = util.serverlessTransformMultiValuesOutgoing(res, event)
            res
}

Keys to transform inbound are: multiValueQueryStringParameters->queryStringParameters and multiValueHeaders->headers. Outbound there are only headers so headers->multiValueHeaders

from serverless-http.

dougmoscrop avatar dougmoscrop commented on July 21, 2024

Released in 1.9.0

from serverless-http.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.