This topic describes handlers and how to configure handlers in a custom container in Function Compute.

What is a handler?

A handler of a function in FC is a method that is used to process requests in the function code.

Handlers are classified into event handlers and HTTP handlers. Event requests are generated by event sources, and HTTP requests are generated by HTTP triggers. For more information, see Function types.

  • If you invoke a custom container function in web server mode, Function Compute uses the handler that you configured to process requests.FC You can use the x-fc-function-handler header in the logic of the HTTP server to obtain the handler configurations for custom processing.
  • If you invoke a custom container function in non-web server mode, FC uses only event handlers but not HTTP handlers to process requests. When the FC function is triggered, Function Compute passes the function event to the container in the form of environment variables. You can use os.GetEnv("FC_CUSTOM_CONTAINER_EVENT") to obtain the event information and perform custom operations.

For more information about the definitions and operations of functions in FC, see Manage functions.

Configure a handler

When you configure a handler, make sure that you follow the configuration specifications that are described in Function Compute. The configuration specifications vary based on the handler type.

For more information about how to configure a handler, see Event handlers and HTTP handlers.