정책은 흐름에 연결될 때까지 실행되지 않습니다. 단계 구성에서 정책 이름을 지정하여 정책 연결을 만들 수 있습니다.
연결 지점 선택은 API 프록시의 동작에 매우 중요합니다. 예를 들어 할당량 정책을 응답 흐름에 연결하면 요청 메시지가 백엔드 서비스로 전송된 후에 할당량이 적용됩니다. 그렇게 되면 할당량 정책 적용 목적이 무효화될 수 있습니다. 따라서 할당량 정책은 요청 흐름의 처리 단계에 연결해야 합니다.
정책 연결의 형식은 다음과 같습니다.
<Step>
<Name>{policy_name}</Name>
</Step>
예를 들면 다음과 같습니다.
<Step>
<Name>QuotaPolicy</Name>
</Step>
ProxyEndpoint 또는 TargetEndpoint 구성의 적절한 요청 또는 응답 흐름 요소에 단계 구성을 추가하여 정책을 흐름에 연결합니다.
요청 또는 응답 흐름에 정책을 연결할 수 있습니다. 요청 및 응답 흐름은 PreFlow 및 PostFlow로 세분화됩니다.
다음 예시는 정책 연결이 없는 최소 ProxyEndpoint 구성을 보여줍니다. (수신)HTTPProxyConnection 및 RouteRule을 정의합니다.
경우에 따라 ProxyEndpoint에서 기타 초기 처리 이후에 정책을 실행하는 것이 좋습니다. 예를 들어 PreFlow에서 할당량을 확인한 후에 요청을 JSON에서 XML로 변환하는 등의 다른 처리 집합을 수행하려고 합니다. 이렇게 하려면 PostFlow 요청 경로에 정책을 연결합니다. 다음은 PostFlow 연결 요청의 예시입니다. 이 정책은 PreFlow(및 조건부 흐름)의 모든 정책이 실행된 후 요청 메시지에서 실행됩니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-18(UTC)"],[[["\u003cp\u003eThis documentation applies to both Apigee and Apigee hybrid platforms.\u003c/p\u003e\n"],["\u003cp\u003ePolicies in Apigee are attached to Flows using a Step configuration within either a request or response flow, and are not executed unless attached.\u003c/p\u003e\n"],["\u003cp\u003eThe attachment point of a policy significantly impacts API proxy behavior, such as attaching a Quota policy to a request Flow to enforce it before any backend processing.\u003c/p\u003e\n"],["\u003cp\u003ePolicies can be attached to PreFlow or PostFlow within request and response Flows, allowing for sequential processing, as demonstrated in the examples.\u003c/p\u003e\n"],["\u003cp\u003eThe name provided to the policy within the step configuration must match exactly the name attribute in the corresponding policy file in the /policies folder.\u003c/p\u003e\n"]]],[],null,["# Attaching a policy to a ProxyEndpoint or TargetEndpoint Flow\n\n*This page\napplies to **Apigee** and **Apigee hybrid**.*\n\n\n*View [Apigee Edge](https://docs.apigee.com/api-platform/get-started/what-apigee-edge) documentation.*\n\nPolicies are not executed until they are attached to a Flow. You can create a Policy\nattachment by naming a Policy in a Step configuration.\n\nThe choice of attachment point is critical to the behavior of your API proxy. For example, if\nyou attach the Quota policy to a response Flow, then the Quota would be enforced *after* the\nrequest message was sent to the backend service. That would defeat the purpose of applying a\nQuota policy! Therefore, you need to attach the Quota policy as a processing Step on the request\nFlow.\n\nThe format of a policy attachment is: \n\n```scdoc\n\u003cStep\u003e\n \u003cName\u003e{policy_name}\u003c/Name\u003e\n\u003c/Step\u003e\n```\n\nFor example: \n\n```text\n\u003cStep\u003e\n \u003cName\u003eQuotaPolicy\u003c/Name\u003e\n\u003c/Step\u003e\n```\n| **Note:** The `{policy_name}` variable must be the same as the `name` attribute in the policy (stored under /policies) that you want to attach. The names must match exactly, as name matching is case-sensitive.\n\nA policy is attached to a Flow by adding the Step configuration to the appropriate request or\nresponse Flow element in a ProxyEndpoint or TargetEndpoint configuration.\n\nYou can attach a policy to a request or response Flow. Request and response Flows are further\nsubdivided in to PreFlow and PostFlow.\n\nThe following example demonstrates the minimal ProxyEndpoint configuration, with no policy\nattachments. It simply defines the (inbound) HTTPProxyConnection and a RouteRule. \n\n```text\n\u003cProxyEndpoint name=\"default\"\u003e\n \u003cHTTPProxyConnection\u003e\n \u003cBasePath\u003e/weather\u003c/BasePath\u003e\n \u003cVirtualHost\u003edefault\u003c/VirtualHost\u003e\n \u003c/HTTPProxyConnection\u003e\n \u003cRouteRule name=\"default\"\u003e\n \u003cTargetEndpoint\u003edefault\u003c/TargetEndpoint\u003e\n \u003c/RouteRule\u003e\n\u003c/ProxyEndpoint\u003e\n```\n\nYou must modify this configuration so that the ProxyEndpoint enforces a Quota policy (as a\nprocessing Step) before the API proxy performs any other processing. If a developer has exceeded\na Quota, you don't want to waste any computational resources on additional requests.\n\nTo enforce this configuration, you attach a processing Step to the request PreFlow as\nfollows: \n\n```text\n\u003cProxyEndpoint name=\"default\"\u003e\n \u003cPreFlow\u003e\n \u003cRequest\u003e\n \u003cStep\u003e\u003cName\u003eQuotaPolicy\u003c/Name\u003e\u003c/Step\u003e\n \u003c/Request\u003e\n \u003c/PreFlow\u003e\n \u003cHTTPProxyConnection\u003e \n \u003cBasePath\u003e/weather\u003c/BasePath\u003e \n \u003cVirtualHost\u003edefault\u003c/VirtualHost\u003e \n \u003c/HTTPProxyConnection\u003e \n \u003cRouteRule name=\"default\"\u003e \n \u003cTargetEndpoint\u003edefault\u003c/TargetEndpoint\u003e \n \u003c/RouteRule\u003e \n\u003c/ProxyEndpoint\u003e\n```\n\nSometimes, you might want a policy to execute after some other initial processing on the\nProxyEndpoint. For example, you want to check Quota in the PreFlow, then perform another set of\nprocessing after Quota is checked, such as converting the request from JSON to XML. To do so,\nattach a policy to the PostFlow request path. The following is a sample request PostFlow\nattachment. This policy would execute on the request message after all of the policies in the\nPreFlow (and any conditional flows) execute. \n\n```text\n\u003cPostFlow\u003e\n \u003cRequest\u003e\n \u003cStep\u003e\u003cName\u003eJSONtoXMLPolicy\u003c/Name\u003e\u003c/Step\u003e\n \u003c/Request\u003e\n\u003c/PostFlow\u003e\n```\n\nThe following is a sample response PostFlow attachment. This policy would execute on the\nresponse message. (The ProxyEndpoint response PostFlow is the final processing phase before the\nresponse is returned to the requesting client app.) \n\n```text\n\u003cPostFlow\u003e\n \u003cResponse\u003e\n \u003cStep\u003e\u003cName\u003eXMLtoJSONPolicy\u003c/Name\u003e\u003c/Step\u003e\n \u003c/Response\u003e\n\u003c/PostFlow\u003e\n```\n| **Tip:** You can also define conditional Flows that execute *between* the PreFlow and PostFlow phases. This is covered in the next topic, [Flow variables and\n| conditions](/apigee/docs/api-platform/fundamentals/flow-variables-and-conditions)."]]