HTTP-triggered function is a function type in SCF. Compared with event-triggered function that has limits on the event format, HTTP-triggered function focuses on optimization of web service scenarios and can directly send HTTP requests to URLs to trigger function execution.
In terms of the support for web service scenarios, HTTP-triggered function excels event function in the following aspects:
Express
and Koa
, to write HTTP-triggered functions. You can also quickly migrate your local web framework services to the cloud with minimal modification.How an HTTP-triggered function works is as shown below:
After your HTTP request passes API Gateway, when directly passing through the native request, API Gateway will add the content required by the gateway to trigger the function, such as function name and function region, to the request header and pass the modified request to the function environment to trigger the backend function.
In the function environment, the built-in proxy is used to implement Nginx-based forwarding, remove the request information not required by the service specification from the header, and send the native HTTP request to your web server service through the specified port.
After being configured with the specified listening port 9000
and service bootstrap file, your web server will be deployed in the cloud and use this port to get HTTP requests for processing.
/tmp
directory is readable and writable. When outputting files, please select the /tmp
path; otherwise, the service will exit exceptionally due to the lack of write permission.scf_bootstrap
is included in the ZIP package. Response headers
has the following limits:key
and value
values cannot exceed 4 KB.body
cannot exceed 6 MB.9000
port and cannot listen on the internal loopback address 127.0.0.1
.Connection
field in the HTTP request header cannot be customized.The common request headers received by your web server from the function environment are as detailed below, none of which can be customized:
Header Field | Description |
---|---|
X-Scf-Request-Id | Current request ID |
X-Scf-Memory | Maximum memory that can be used during function instance execution |
X-Scf-Timeout | Timeout period for function execution |
X-Scf-Version | Function version |
X-Scf-Name | Function name |
X-Scf-Namespace | Function namespace |
X-Scf-Region | Function region |
X-Scf-Appid | Appid of function owner |
X-Scf-Uin | Uin of function owner |
Was this page helpful?