I have a series of HTTP endpoints that involve lambda functions that hit detail end points like so:
products/1
users/1
package/998134
There is not a corresponding endpoint for products/
, users/
or package/
. I have a custom authorizer around the users/{id}
and package/{id}
endpoints.
If a user goes to users/
or packages/
using GET
they receive {"message":"Missing Authentication Token"}
. If they hit these end points with POST
(a valid option for my endpoint if they were to also pass the ID) they receive
{'message': "Authorization header requires 'Credential' parameter. Authorization header requires 'Signature' parameter. Authorization header requires 'SignedHeaders' parameter. Authorization header requires existence of either a 'X-Amz-Date' or a 'Date' header. Authorization=MYTOKENHERE"}
Is there a way to adjust either of these messages? My first thought was to just create that associated end points:
GET users/
POST users/
GET products/
POST products/
GET package/
POST package
But that quickly gets to be a lot of work because I have more than three of these end points to do. I also need to include DELETE
on a few of those.
Can I easily create a response for invalid or incomplete endpoints?
My serverless.yml has definitions that look like this currently:
show_user:
handler: users/show_users.return_user
events:
- http:
path: users/{id}
method: get
cors: true
update_user:
handler: users/update_user.update_user
events:
- http:
path: users/{id}
method: post
cors: true
authorizer: ${self:custom.authorizer.users}