dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.2k stars 794 forks source link

Support for integration HTTP_PROXY #1072

Closed e-compton closed 2 years ago

e-compton commented 4 years ago

Feature Request

Serverless supports creating HTTP and HTTP_PROXY type integrations in its API Gateways. We're using them to route certain requests to our backend servers. It would be really helpful if we could run this locally and forward the requests along in the same way locally.

https://github.com/serverless/serverless/pull/3534

Sample Code

service: test

provider:
  name: aws
  runtime: nodejs12.x

functions:
  hello:
    handler: handler.dummy
    events:
      - http:
          path: v1/repository
          method: get
          integration: http-proxy
          connectionType: vpc-link
          connectionId: 12345
          request:
            uri: http://www.github.com/v1/repository

plugins:
  - serverless-offline
'use strict';

module.exports = {
  dummy: async () => ({ body: 'Dummy response' })
};

Expected behavior/code

Currently, when a request is made to http://localhost:3000/dev/v1/repository it returns back a blank response.

Instead, it would forward the request to http://www.github.com/v1/repository and return the response of that request.

btruhand commented 3 years ago

@e-compton did you ever get to resolve or improve on this on your side? this is something that I would like to also have for my team. If not, I can try to put time and tackle this

HTTP proxy forwarding do work using with cloudformation templates, but it leaves much to be desired in its current state for me. Specifically there is no support for HTTP integration (non-proxy) and also authorizer is completely bypassed.

So the possibilities are:

  1. expand current handling of HTTP integration in serverless schema
  2. expand the support for defining routes based on cloudformation template to include HTTP integration

I think the first option will be an easier and more natural undertaking considering that the integration does get setup, but incorrectly so. Specifically:

  1. A handler function needs to be defined else an error will occur, even if the handler function should not be used
  2. The handler function is the one being forwarded to, and not the specified URI

From there I am hoping the integration with authorizer would be fairly straightforward (reuse current capabilities)

I hope others can give feedback on my thoughts, it's my first time really working with the serverless framework (and probably in a confused manner considering my team isn't using much of lambda functions)

jeremygottfried commented 3 years ago

Hi is there any update or roadmap for this issue to be fixed?