Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable mixed API usage with same routes #1737

Open
JaroVDH opened this issue Sep 29, 2023 · 0 comments
Open

Enable mixed API usage with same routes #1737

JaroVDH opened this issue Sep 29, 2023 · 0 comments

Comments

@JaroVDH
Copy link

JaroVDH commented Sep 29, 2023

Feature Request

This is an uncommon use case, but it's possible to have multiple endpoints with the same route if you have both REST & HTTP in use.
For example, if you're migrating from one to the other and run them in parallel:

functions:
  main:
    handler: src/index.handle
    events:
      - http:
          path: /
      - httpApi:
          path: /

Or if you have two fully distinct APIs that just happen to have matching paths in routes:

functions:
  oneApi:
    handler: src/one/index.handle
    events:
      - http:
          path: /{proxy}
  otherApi:
    handler: src/other/index.handle
    events:
      - httpApi:
          path: /{proxy}

Currently Serverless Offline will fail with AssertError: New route X conflicts with existing X.

Expected behavior
I'm not sure what the best way to handle this would be.
Some ways this could be handled:

  1. Custom prefix per event type
custom:
  serverless-offline:
    prefix:
      http: "rest"
      httpApi: "http"

Overloading the prefix type would make the documentation more confusing, though.

  1. Ignoring some event types

You could then run multiple instances of sls offline which ignore different sets of events.

custom:
  serverless-offline:
    ignoreEvents:
      - httpApi
  1. Prepend event in url?
custom:
  serverless-offline:
    prependEventInUrl: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant