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

URL path parameters are not honored #182

Open
ewrogers opened this issue Aug 15, 2019 · 1 comment
Open

URL path parameters are not honored #182

ewrogers opened this issue Aug 15, 2019 · 1 comment

Comments

@ewrogers
Copy link

ewrogers commented Aug 15, 2019

I'm not sure if this is a bug or maybe a feature request, but I have seen some other projects using URL paths in their serverless.yaml.

For example:

functions:
  get-users:
    handler: handler.getUsers
    events:
      - http:
          method: GET
          path: "${self:custom.apiPrefix}/users"
  get-user-by-id:
    handler: handler.getUserById
    events:
      - http:
          method: GET
          path: "${self:custom.apiPrefix}/users/{id}"
          request:
            parameters:
              paths:
                id: true

However, it seems this is not used by the Kubeless platform. Both requests route to the get-users function.

Am I missing something, or are URL path parameters not supported? That is kind of a big deal for REST APIs, what are the current workarounds? I can't imagine no one has this problem...

I have considered serverless-http + koa + koa-router but that almost removes the entire point of route definitions here...

@andresmgot
Copy link
Contributor

The path should be resolved to the path in the ingress object that is created. At the end of the day those are translated to ingress parameters so you can check what's being used if you execute kubectl get ingress -o yaml <ingress_name>.

I think that your problem may be related to the {id} parameter you are trying to use. I think that the proper way of using that would be to use a regexp there:

https://kubernetes.github.io/ingress-nginx/user-guide/ingress-path-matching/

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

2 participants