Different function for different path and method

Hi All,

When we are creating serverless.yml file can we point different handler function for different http.methods and http.path. Default structure which I can achieve is pointing to same function for all methods and path

handler: handler.hello
- http:
path: first-endpoint
method: get
- http:
path: first-endpoint
method: post

Here i want to point to different function for get & post methods maybe function1 & function2

Hi Baharul,

Lambda considers different “handlers” to be separate functions. So if you want to have a get call to /first-endpoint access your handler.hello function and a post call to access handler.hello-post, then you would define two functions in your serverless.yml file.

If you want both a get and a post to access the same handler, then your example above would route both methods to the same handler function.