Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants