簡體   English   中英

WSO2 API管理器v1.8.0

[英]WSO2 API Manager v1.8.0

我有一個簡單的用例,即從API使用者到后端API端點的映射路徑參數。 我已經做了很多研究,但是還沒有找到具體的答案。 根據我的理解,不使用uri模板就無法完成path參數的映射。 現在的問題是,API管理器不支持API Publisher用戶界面中的uri-template,而必須使用url-mapping。 WSO2開發人員的一個博客說,您可以轉到單個突觸配置並將其手動更改為uri-template。 但是,實際上發生的是,對synapde配置所做的更新以某種方式觸發了可能會從發布者UI發生的數據庫更新,最終結果是它不起作用。 有人可以提供如何映射路徑參數的方法嗎? 僅供參考-查詢參數映射對我來說是有用的,因為它不需要uri-template,並且可以使用url-mapping本身實現。

APIM 1.8同時支持uri-template和url-mapping。您可以在資源部分下定義url-template(或者如果要uri-mapping)。 請參閱我添加了url-template和url-mapping的synapse配置

在發布者中,我為URL映射添加了/ json作為URL模式,為uri-template添加了/ json / {id}

    <?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse"
     name="admin--mytst"
     context="/mytest"
     version="1"
     version-type="url">
   <resource methods="GET" url-mapping="/json" faultSequence="fault">
      <inSequence>
         <filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION">
            <then>
               <send>
                  <endpoint name="admin--mytst_APIproductionEndpoint_0">
                     <http uri-template="http://localhost.com"/>
                  </endpoint>
               </send>
            </then>
            <else>
               <sequence key="_sandbox_key_error_"/>
            </else>
         </filter>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </resource>
   <resource methods="GET" uri-template="/json/{id}" faultSequence="fault">
      <inSequence>
         <filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION">
            <then>
               <send>
                  <endpoint name="admin--mytst_APIproductionEndpoint_1">
                     <http uri-template="http://localhost.com"/>
                  </endpoint>
               </send>
            </then>
            <else>
               <sequence key="_sandbox_key_error_"/>
            </else>
         </filter>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </resource>
   <handlers>
      <handler class="org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler"/>
      <handler class="org.wso2.carbon.apimgt.gateway.handlers.throttling.APIThrottleHandler">
         <property name="id" value="A"/>
         <property name="policyKey" value="gov:/apimgt/applicationdata/tiers.xml"/>
      </handler>
      <handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageHandler"/>
      <handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtGoogleAnalyticsTrackingHandler">
         <property name="configKey" value="gov:/apimgt/statistics/ga-config.xml"/>
      </handler>
      <handler class="org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler"/>
   </handlers>
</api>`enter code here`

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM