HTTP Service [Deprecated]
중요
타사 서비스 & 푸시 알림 사용 중단
App Services의 타사 서비스 및 푸시 알림은 함수에서 외부 종속성을 사용하는 HTTP 엔드포인트를 만들기 위해 더 이상 사용되지 않습니다.
웹훅은 동작에 대한 변경 없이 HTTPS 엔드포인트로 이름이 변경되었습니다. 기존 웹훅을 마이그레이션해야 합니다.
기존 서비스는,9월까지 30 계속2025 작동합니다.
타사 서비스 및 푸시 알림은 이제 더 이상 사용되지 않으므로 App Services UI에서 기본적으로 제거되었습니다. 기존 타사 서비스 또는 푸시 알림을 관리해야 하는 경우 다음을 수행하여 구성을 UI에 다시 추가할 수 있습니다.
왼쪽 탐색 메뉴의 Manage 섹션에서 App Settings을(를) 클릭합니다.
Temporarily Re-Enable 3rd Party Services 옆의 토글 스위치를 활성화한 다음 변경 사항을 저장합니다.
개요
The Atlas App Services HTTP Service is a generic interface that enables you to communicate with any service that is available over HTTP, such as those that provide a REST API. This is useful when you need to use a service that does not have a custom service built-in to App Services.
To send an outbound HTTP request, call one of the HTTP actions.
To handle incoming requests from an external service, configure an incoming webhook and provide it to the service, if possible. See the incoming webhooks section on this page for an example.
구성 매개변수
You will need to provide values for the following parameters when you create an HTTP service interface:
{ "name": "<Service Name>", "type": "http", "config": {} }
Parameter | 설명 |
---|---|
Service Name config.name | The name of this HTTP service interface. This must be unique from all other service interfaces in your application. |
서비스 조치
The HTTP service in App Services provides the following actions that you can call in 함수 and in the SDKs. Each action maps to a standard HTTP request method.
For instructions on using an HTTP service action, see Call a Service Action.
참고
You must enable a service action in a service rule before you can call it.
작업 | 설명 |
---|---|
Send an HTTP GET request. | |
Send an HTTP POST request. | |
Send an HTTP PUT request. | |
Send an HTTP PATCH request. | |
Send an HTTP DELETE request. | |
Send an HTTP HEAD request. |
수신 Webhooks
참고
Convert HTTP Webhooks to Endpoints
HTTP Service webhoooks are deprecated in favor of custom HTTPS endpoints. You can automatically migrate your existing webhooks to endpoints in one-click. To learn how, see Convert Webhooks to HTTPS Endpoints.
구성
You will need to provide values for the following parameters when you configure an HTTP incoming webhook:
You will need to provide a configuration file of the following form when you configure an HTTP incoming webhook:
{ "name": "<Webhook Name>", "can_evaluate": { <JSON Expression> }, "run_as_authed_user": <Boolean>, "run_as_user_id": "<App Services User ID>", "run_as_user_id_script_source": "<Function Source Code>", "respond_result": <Boolean>, "fetch_custom_user_data": <Boolean>, "create_user_on_auth": <Boolean>, "options": { "httpMethod": "<HTTP Method>", "validationMethod": "<Webhook Validation Method>", "secret": "<Webhook Secret>" } }
구성 값 | 설명 |
---|---|
Webhook Name name | 필수입니다. 웹훅의 이름입니다. 참고Each incoming webhook in an HTTP service interface must have a unique name. |
Respond With Result respond_result | Required. If |
Run Webhook As run_as_user_id run_as_user_id_script_source | 선택 사항. 웹훅이 호출될 때 웹훅 함수를 실행하는 App Services 사용자 의 ID입니다.
|
HTTP Method options.httpMethod | The HTTP method that incoming webhook requests should use. You can configure a webhook to accept any method or specify a specific method. The following methods are supported:
|
Request Validation options.validationMethod | The request validation method incoming requests should use. The following validation types are supported:
|
Secret options.secret | If Request Validation is enabled, this is the validation secret. |
요청 페이로드
App Services automatically passes a payload
document as the first argument
to incoming webhook functions. In an HTTP Service incoming webhook the
payload
object represents an incoming HTTP request and has the
following form:
{ "query": <query parameters>, "headers": <request headers>, "body": <request body (BSON)> }
필드 | 설명 | ||||
---|---|---|---|---|---|
| A document where each field corresponds to a query parameter that the external service included in the webhook URL. 예시A request sent to a webhook URL with the query parameters
| ||||
| A document where each field corresponds to an HTTP header that the external service included in the webhook URL. 예시A request sent to a webhook URL with a
| ||||
| A BSON.Binary object encoded from the request body. You can access the request body by serializing the binary object to a string and then parsing the string to EJSON:
|
웹훅 함수 예시
The following webhook function inserts incoming data into a MongoDB
collection and returns the insertedId
in the response body
.
exports = function(payload, response) { const mongodb = context.services.get("mongodb-atlas"); const requestLogs = mongodb.db("test").collection("requestlogs"); requestLogs.insertOne({ body: EJSON.parse(payload.body.text()), query: payload.query }).then(result => { response.setStatusCode(201); response.setBody(result.insertedId); }) };