[英]How to Configure Path Params in Wso2 API manager 1.8?
我正在使用Wso2 API Manager 1.8。 我想知道如何配置路徑參數
這是動態的。 我將通過以下示例進行說明
My API starts with context api/example/ and i have an end point
http://users/api/example/{Id}.json
How to map the id variable with coming id value . ?
我想加載給定值的'id'並相應顯示結果。 我怎樣才能做到這一點 ?
在突觸中,您可以讀取添加到屬性的參數,如下所示
<property name="val1" expression="get-property('uri.var.param1')"/>
<property name="val2" expression="get-property('uri.var.param1')"/>
然后,可以使用REST_URL_POSTFIX屬性[1]將這些值附加到生產url,如下所示。
<property name="REST_URL_POSTFIX" expression="fn:concat('/',$ctx:val1,'/',$ctx:val2)" scope="axis2"/>
這會將值附加到生產網址->,例如http:// ip / mytest / param1 / param2 。
wso2 apimanger支持自定義中介擴展[2]。因此,您可以添加一個insquence並在其中添加邏輯。
1. https://docs.wso2.com/display/ESB470/HTTP+Transport+Properties 2. https://docs.wso2.com/display/AM180/Adding+Mediation+Extensions
您可以為此使用url-templates。
創建API時,請添加資源,如下所示
在url-pattern / {context} / {version} / {id}.json
這會將帶有http://users/api/example/{Id}.json
模式的任何請求定向到上述資源。
注意:如果尚未將API版本設置為默認版本,並說在創建API時已將版本設置為1.0.0,則可能需要按以下方式調整請求。 (僅在上下文部分之后,您需要添加API版本) http://users/api/example/1.0.0/{Id}.json
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.