10

I'm pretty excited about HTTP Gateways due to the drastically reduced pricing in comparison to REST Gateways, but I'm stuck on creating routes that do not completely blow up my serverless.yml file.

The documentation for HTTP Gateway at Serverless describes this to define routes:

functions:
 params:
 handler: handler.params
 events:
 - httpApi:
 method: GET
 path: /get/for/any/{param}

There is a support for '*', but this causes issues with OPTIONS cause those will overwrite the created CORS policies (so OPTIONS requests would actually get to the application, which does not make any sense, especially if the route is protected via an authorizer).

Also, it's not possible to define multiple methods.

# does not work
method: GET,POST,DELETE
# also not possible
method:
 - GET
 - POST
 - DELETE

The only configuration I found is to define all routes separately:

events:
 - httpApi:
 path: /someApi/{proxy+}
 method: GET
 - httpApi:
 path: /someApi/{proxy+}
 method: POST
 - httpApi:
 path: /someApi/{proxy+}
 method: DELETE

This works fine & the UI is even bundling the routes cause they're on the same prefixed path:

enter image description here

But with this I have to define all HTTP methods for all my main resources separately including the attached authorizer.

Is there some way to combine this?

asked Jul 28, 2020 at 17:40
1
  • 1
    I'm also looking for the same thing and I think this is the only way to do it for now. Maybe it's worth requesting this feature on the Serverless GitHub Commented May 13, 2021 at 15:04

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.