조건은 request.verb흐름 변수를 참조합니다. 흐름 변수는 Apigee에서 처리하는 API 트랜잭션과 관련된 상태 정보를 포함하는 이름이 지정된 참조입니다. Apigee는 참조할 수 있는 여러 상태 변수를 정의합니다.
예 2
서비스 백엔드가 날씨 보고서와 날씨 예측을 제공하는 경우 API가 이러한 API 리소스에 매핑되는 두 개의 조건부 흐름(/reports 및 /forecasts)을 정의할 수 있습니다. API 호출의 URL에 이러한 리소스 중 하나가 포함되면 조건이 true로 평가되고 조건부 흐름에 연결된 로직이 실행됩니다.
[[["이해하기 쉬움","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-07-16(UTC)"],[[["\u003cp\u003eConditional flows in Apigee execute policies only if their defined condition evaluates to \u003ccode\u003etrue\u003c/code\u003e, unlike PreFlow or PostFlow policies that always run.\u003c/p\u003e\n"],["\u003cp\u003eOnly one conditional flow per segment is executed during a request and response, specifically the first flow whose condition is met.\u003c/p\u003e\n"],["\u003cp\u003eConditional flows can be based on HTTP verbs like \u003ccode\u003eGET\u003c/code\u003e or URL resources like \u003ccode\u003e/reports\u003c/code\u003e and \u003ccode\u003e/forecasts\u003c/code\u003e, leveraging flow variables such as \u003ccode\u003erequest.verb\u003c/code\u003e and \u003ccode\u003eproxy.pathsuffix\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAdding a conditional flow can be done in either the New Proxy Editor or the Classic Proxy Editor, allowing for customized execution logic based on specific request characteristics.\u003c/p\u003e\n"],["\u003cp\u003ePolicies, like a Quota policy, can be attached to a conditional flow to enforce certain rules, such as limiting request frequency, for requests matching the flow's condition.\u003c/p\u003e\n"]]],[],null,["*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\nIn a conditional flow,\npolicies are executed only if the flow's condition evaluates to\n`true` (as opposed to policies attached to the PreFlow or PostFlow,\nwhich are always executed). This section describes how to create a conditional flow.\n\nAbout conditional flows\n\nDuring the processing of a request and response, only one conditional flow is executed per\nsegment---the first flow whose condition evaluates to `true`.\nYou can create conditions that include `||`(OR) and `&&`(AND) operators. However, by default, the `||` operator has higher precedence than the `&&` operator. For example, a condition written as ` A && B || C && D` is evaluated as `A && (B || C) && D`. Make sure to parenthesize the expression if you want to change the precedence when using these operators.\n\nThe following examples illustrate some ways to use conditional flows.\n\nExample 1\n\nThe following ProxyEndpoint definition shows a conditional flow that is executed\nby the ProxyEndpoint on any `HTTP GET` request to the API proxy: \n\n```text\n\u003cProxyEndpoint name=\"default\"\u003e\n \u003cPreFlow\u003e\n \u003cRequest/\u003e\n \u003cResponse/\u003e\n \u003c/PreFlow\u003e\n \u003cFlows\u003e\n \u003cFlow name=\"Flow-1\"\u003e\n \u003cCondition\u003erequest.verb=\"GET\"\u003c/Condition\u003e\n \u003cRequest/\u003e\n \u003cResponse/\u003e\n \u003c/Flow\u003e\n \u003c/Flows\u003e\n \u003cPostFlow\u003e\n \u003cRequest/\u003e\n \u003cResponse/\u003e\n \u003c/PostFlow\u003e\n ...\n\u003c/ProxyEndpoint\u003e\n```\n\nNotice that the condition references the `request.verb`\n[*flow\nvariable*](/apigee/docs/api-platform/fundamentals/introduction-flow-variables). A flow variable is named references that hold state information associated\nwith an API transaction processed by Apigee. Apigee defines many state variables that you can\nreference.\n\nExample 2\n\nIf your\nservice backend provides weather reports and weather forecasts, your API might define two\nconditional flows that map to those API\nresources: `/reports` and `/forecasts`. When an API call\nincludes one of those resources in the URL, the condition evaluates to true and the logic\nattached to the conditional flow is executed.\n\nApp developers then access your resources by making requests to a URL in the form: \n\n```text\nhttp://myAPIs.myCo.com/weather/reports\n```\n\nor: \n\n```text\nhttp://myAPIs.myCo.com/weather/forecasts\n```\n\nIn an API proxy, you can define a conditional flow that corresponds to a specific\nresource: \n\n```text\n\u003cProxyEndpoint name=\"default\"\u003e\n \u003cPreFlow\u003e\n \u003cRequest/\u003e\n \u003cResponse/\u003e\n \u003c/PreFlow\u003e\n \u003cFlows\u003e\n \u003cFlow name=\"Flow-1\"\u003e\n \u003cCondition\u003e(proxy.pathsuffix MatchesPath \"/reports\")\u003c/Condition\u003e\n \u003cRequest/\u003e\n \u003cResponse/\u003e\n \u003c/Flow\u003e\n \u003cFlow name=\"Flow-2\"\u003e\n \u003cCondition\u003e(proxy.pathsuffix MatchesPath \"/forecasts\")\u003c/Condition\u003e\n \u003cRequest/\u003e\n \u003cResponse/\u003e\n \u003c/Flow\u003e\n \u003c/Flows\u003e\n \u003cPostFlow\u003e\n \u003cRequest/\u003e\n \u003cResponse/\u003e\n \u003c/PostFlow\u003e\n ...\n\u003c/ProxyEndpoint\u003e\n```\n\nIn this example, you reference the `proxy.pathsuffix` flow variable,\nwhich contains the suffix portion of the URL used to access the API proxy. You can then attach\ndifferent policies to the conditional flow for each resource.\n\nExample: Creating a conditional flow\n\nThe next example:\n\n- Creates a conditional flow that executes only when the request message is an HTTP `GET`.\n- Adds a policy to the new flow.\n\nAdding a conditional flow \n\nApigee in Cloud console\n\nTo add a conditional flow:\n\n1. Select the **Develop** tab in the Proxy Editor.\n2. Select **Proxy endpoints \\\u003e default** in the left-hand pane.\n\n **Note:** You may need to expand the visual editor in the right-hand pane to see all the\n elements.\n To do so, click and drag the divider between the visual editor and the text editor\n down a little.\n3. Click the **+** button above the **Response** pane.\n\n4. In the **Add conditional flow** dialog, select **Path and verb** , and in the **Path** field, enter the path suffix that you want to be in the request path in order for the conditional flow to execute. See [Example 2](#example-2) above. **Note:** If you don't want to include a path condition, simply enter **/** in the **Path** field, as shown below. This will be matched for any request.\n\n The conditional flow only executes if the request is\n a `GET` request (but not for `PUT`, `POST`, etc.).\n\n The new flow, called `Flow-1`, now appears in the **Proxy Endpoint** pane.\n\n5. The XML code for the new conditional flow is displayed in the text editor.\n\nYou can edit the **Condition** element if you wish. See\n[Adding logic\nto flows](/apigee/docs/api-platform/fundamentals/what-are-flows#addinglogictoflows).\n\nAttaching a policy to the flow\n\nNow that you have created the conditional flow, you can attach a policy to it. The next example\nadds a Quota policy, which restricts the number of request messages that an API proxy allows over\na period of time, to the flow:\n\n1. In the left-hand pane, click the **+** button to the right of **Policies**.\n2. In the **Create policy** dialog, click in the **Select policy type** field and scroll down to **Traffic Management** and select **Quota**.\n3. Click **Create** to create the policy.\n4. Click the **+** button next to **Flow-1** in the **Request** pane.\n\n5. In the **Add policy step** dialog, click in the **Select existing policy** field and select **Quota-1**.\n6. Click **Add**.\n\nThe **Request** pane now displays the flow and attached policy, **Quota-1**.\n\nThe text editor now displays a step containing the **Quota-1** policy in the\n**Flow-1** element of the XML:\n\nWith this configuration, the Quota policy will be enforced for `GET` requests.\nRequests of other types will not contribute to the maximum number of requests in the Quota policy.\n\nClassic UI\n\nTo add a conditional flow, select the **Develop** tab in the API proxy builder.\n\nClick in the desired endpoint.\n\nThe **New Conditional Flow** form lets you name the flow and configure a condition. In the\nfollowing example, you add a simple condition that evaluates the HTTP of the request message for\na `GET` verb (as opposed to `PUT`, `POST`, etc.) on any URI after the base path.\n\n(Learn how to construct conditional statements in\n[Conditions with\nflow variables](/apigee/docs/api-platform/fundamentals/flow-variables-and-conditions).)\n\nThe new flow, called `Flow-1`, now appears in the Navigator menu.\n\nNow observe the XML configuration for the ProxyEndpoint. Select **Flow-1** in the\n**Navigator** menu.\n\nYou will see the following configuration. \n\n```scdoc\n\u003cPreFlow name=\"PreFlow\"\u003e\n \u003cRequest/\u003e\n \u003cResponse/\u003e\n\u003c/PreFlow\u003e\n\u003cFlows\u003e\n \u003cFlow name=\"Flow-1\"\u003e\n \u003cRequest/\u003e\n \u003cResponse/\u003e\n \u003cCondition\u003e(proxy.pathsuffix MatchesPath \"/**\") and (request.verb = \"GET\")\u003c/Condition\u003e\n \u003c/Flow\u003e\n\u003c/Flows\u003e\n\u003cPostFlow name=\"PostFlow\"\u003e\n \u003cRequest/\u003e\n \u003cResponse/\u003e\n\u003c/PostFlow\u003e\n```\n\nOnce you have created a conditional flow, it is available for policy attachment. With the flow\nselected, click the **+ Step** icon in the request or response diagram to add a\nnew or existing policy to the flow.\n\nBy attaching the policy to the selected flow, you are configuring the API proxy to enforce the\nQuota policy only for requests made to that flow URI and verb combination. For example, if you\nattach the policy to the **learn** flow in the request, the following XML is\ngenerated in the text editor: \n\n```scdoc\n\u003cProxyEndpoint name=\"default\"\u003e\n...\n \u003cFlow name=\"issue\"\u003e\n \u003cDescription/\u003e\n \u003cRequest\u003e\n \u003cStep\u003e\n \u003cName\u003eQuota-2\u003c/Name\u003e\n \u003c/Step\u003e\n \u003c/Request\u003e\n \u003cResponse/\u003e\n \u003cCondition\u003e(proxy.pathsuffix MatchesPath \"/issue/**\") and (request.verb = \"GET\")\u003c/Condition\u003e\n \u003c/Flow\u003e\n...\n\u003c/ProxyEndpoint\u003e\n```\n\nIn this configuration, if a `GET` request comes in on the API proxy with a URI\npattern of ...**/issue/\\*\\*** (/issue/ with anything in the URI after the last forward\nslash), quota is enforced on that API call.\n\nNext steps\n\nThe following topics provide more detail about constructing conditions and using\nvariables:\n\n- [Using flow variables](/apigee/docs/api-platform/fundamentals/introduction-flow-variables)\n- [Conditions with flow variables](/apigee/docs/api-platform/fundamentals/flow-variables-and-conditions)"]]