I was reading this blog post from Serverless about the different patterns that exist for Serverless architecture.
I'm interested in the services pattern and thought I'd try it out.
With this configuration in my serverless.yml file.
functions:
apps:
handler: handler.apps
events:
- http: post apps
cors: true
- http: patch users
- http: get users
cors: true
- http: delete users
The following output comes from running serverless deploy.
POST - https://x7lpwa04.execute-api.us-west-2.amazonaws.com/staging/users
PATCH - https://x7lpwa04.execute-api.us-west-2.amazonaws.com/staging/users
GET - https://x7lpwa04.execute-api.us-west-2.amazonaws.com/staging/users
DELETE - https://x7lpwa04.execute-api.us-west-2.amazonaws.com/staging/users
Now in a CRUD service if I wanted to get a single resource, I'd probably have something like this for a get endpoint, /staging/users/{id}. With the above pattern, is it up to the user to pass in a query string parameter like this /staging/users?id={id} instead of having a path parameter like this /staging/users/{id}? Is it possible to get the endpoint to have a path parameter?
It doesn't seem like the path can be overwritten this way.
Aucun commentaire:
Enregistrer un commentaire