All Products
Search
Document Center

Function Compute:Handlers

更新時間:Mar 18, 2024

You can use a Node.js handlers to respond to received events and execute corresponding business logic. This topic describes the concepts, features, and examples of handlers in Node.js runtimes.

What is a handler?

A handler for a function in Function Compute is the method that is used to process requests in function code. When the function is invoked, Function Compute uses the handler that you configured to process requests. You can configure a handler for a function by using the Request Handler parameter in the Function Compute console.

For Function Compute functions that run in Node.js runtimes, handlers follow the File name.Method name format. For example, if your file name is index.js or index.mjs and your method name is handler, the request handler is index.handler.

For more information about functions in Function Compute and related operations, 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.

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.

For examples on how to configure a handler, see Event handlers and HTTP handlers.

More information

For more information about how to deploy your code package to Function Compute, see Deploy a code package.