Code Monkey home page Code Monkey logo

Comments (6)

willfarrell avatar willfarrell commented on June 9, 2024

Checking for a match on resource (v1) or routeKey (v2) shouldn't be too hard to include, but I don't think it's necessary.

Try adding in /{stage} to the start of your path:

const routes = [
  {
    method: 'GET',
    path: '/{stage}/tenants',
    handler: getHandler
  }
]

This should do it for you. I would recommend you validate the pathParameter stage is one of the allowed values configured in API Gateway as well.

from middy.

florianbepunkt avatar florianbepunkt commented on June 9, 2024

Iβ€˜m not sure if I understand what you are proposing. What has the stage to do with it/how would that help?

from middy.

willfarrell avatar willfarrell commented on June 9, 2024

{stage} == identity or anything else in this case, stage is just the term I've heard used with this pattern.

from middy.

florianbepunkt avatar florianbepunkt commented on June 9, 2024

Ah okay. I see. This is what I did actually, but it leads to strange inconsistencies. For example testing an endpoint in the api gateway console throws a route not found error (since the base path is stripped) while testing the same path e2e works fine. Itβ€˜s a weird behaviour in aws but using the resource key would work around that.

from middy.

willfarrell avatar willfarrell commented on June 9, 2024

For example testing an endpoint in the api gateway console throws a route not found error (since the base path is stripped) while testing the same path e2e works fine.
Ohhhh, that's interesting. Might be worth reporting to AWS?

Alternatively you could have 1 lambda per endpoint, and not need the router all together. This is the approach I use, most so I can have an IAM role for each endpoint.

I'm going to close this issue, I don't see us adding in logic only for console testing support (sorry).

from middy.

florianbepunkt avatar florianbepunkt commented on June 9, 2024

Understood. AWS logic is correct. This was never about adding logic but fixing the existing logic to be in line with Api Gateway concepts, where (internal) routing happens independently of the base path. With the workaround that you suggested a service now needs to know its place (base pth, e. g identity) in a stitched/federated or versioned api. That is acceptable knowledge creep in most cases, so it probably does not warrant the effort, since the logic is easy to fork/adapt.

from middy.

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.