Prepare a Function

The first step to create your own Serverless Function is coding it. Currently, you can do this using Python or Go by choosing the appropriate language template.

Each template gives you a basic structure to find a single Function within which all the tasks must run. This is your main Function, and everything starts and ends with it. You can (and probably should) use auxiliary Functions to refactor your code, but make sure the main Function is there. Please don't rename it or change its definition.

This main Function has some input parameters that will give you the context of the HTTP request made to invoke the function:
  • Path
  • Method (POST, GET, PUT, PATCH, or DELETE)
  • Headers
  • Query Parameters
  • Body

This information is the data you can provide to your Function.

When the task of your Function has finished, you will probably want to return some result or feedback in your response. For this you can:
  • Set a status code
  • Use the response body
  • Add headers to the response
The details on how to get the request data and how to set the response info is language and template specific, so check the documentation about the template you want to use to build your Function:
  • Go template documentation
  • Python template documentation