In our velocity template we are conditionally deciding when the url-mapping
attribute or uri-template attribute should be used in the synapse config
generated for each API, eher is the velocity template logic,

#if($resource.getUriTemplate().contains("{") ||
        ($resource.getUriTemplate().contains("*") &&
!$resource.getUriTemplate().endsWith("/*")))
        *uri-template=*"$resource.getUriTemplate()"
        #else
        *url-mapping=*"$resource.getUriTemplate()"
        #end

So we are specifying this attribute based on API Managers requirement. The
synapse engine does not consider this as invalid so we expect that the
synapse engine should honour the attribute defined.

So we need the functionality of both the uri-template and url-mapping
attributes for our HTTP endpoint based APIs, but not at the same time
obviously. Its either one or the other for a given resource. By specifying
these two attributes we are already implying that we are expecting
different functionality(the user expects the same). So its a bit difficult
justifying having to manually set this from the publisher.

WDYT?

On 24 July 2015 at 13:45, Isuru Udana <isu...@wso2.com> wrote:

> Hi Uvindra,
>
> I think the correct approach is to completely remove REST_URL_POSTFIX
> getting appended for HTTP Endpoint. And append only if the user configure
> to do so.
> Initially we implemented HTTP Endpoint in that way. But somehow
> implementation has changed now.
> I am not sure whether we are too late to revert to the original
> implementation now.
>
> If we cannot revert back,
> For ESB, we can simply remove the REST_URL_POSTFIX from the config and for
> AM, we need a easy way to do that from UI.
>
> On Fri, Jul 24, 2015 at 1:31 PM, Uvindra Dias Jayasinha <uvin...@wso2.com>
> wrote:
>
>> We need to come up with $subject.
>>
>> The issue related to this has been highlighted in [1]
>>
>> The REST_URL_POSTFIX property appends the url-mapping of a given resource
>> to the end of the api endpoint in synapse. This is applied by synapse for
>> all APIs that are defined.
>>
>> For example,
>>
>> *API URL* - http://localhost:8280/noPathParam/1.0/
>> *Endpoint URL* - http://localhost:8281/sampleAPI
>> *GET Resource(url-mapping)* - somepath
>>
>> Now invoking the above GET resource of the API,
>>
>>                    GET http://localhost:8280/noPathParam/1.0/somepath
>>
>> will translate to,
>>
>>                     GET http://localhost:8281/sampleAPI/somepath
>>
>>
>>
>> The problem happens when there are Query Parameters. Since resource
>> url-mapping or uri-template attribute is getting appended by default to the
>> end of the URL, it is getting added after the Query Parameter, as follows,
>>
>>
>> *API URL* - http://localhost:8280/pathParam/1.0/
>> *Endpoint URL* - http://localhost:8281/sampleAPI?name={uri.var.name}
>> *GET Resource(url-template)* - {name}
>>
>> Now invoking the above GET resource of the API
>>
>>                    GET http://localhost:8280/pathParam/1.0/somename
>>
>>
>> will translate to,
>>
>>                     GET http://localhost:8281/sampleAPI?name=
>> *somename/somename*
>>
>> instead of the expected,
>>
>>                     GET http://localhost:8281/sampleAPI?name=somename
>>
>>
>> So the problem here is that synapse treats both url-mapping and
>> url-template resources the same way. What should happen is that the
>> REST_URL_POSTFIX property should only be considered if the url-mapping
>> attribute is specified *and not when uri-template attribute exists*.
>>
> There is no url mapping involved with HTTP endpoint (only url template is
> there). And there is no relationship between API resources and HTTP
> Endpoint.
>
> Thanks.
>
>>
>>
>> So can we get this fixed at synapse level? We believe this is the correct
>> place to solve this issue
>>
>>
>> [1] https://wso2.org/jira/browse/APIMANAGER-4002
>>
>> --
>> Regards,
>> Uvindra
>>
>> Mobile: 777733962
>>
>
>
>
> --
> *Isuru Udana*
> Associate Technical Lead
> WSO2 Inc.; http://wso2.com
> email: isu...@wso2.com cell: +94 77 3791887
> blog: http://mytecheye.blogspot.com/
>



-- 
Regards,
Uvindra

Mobile: 777733962
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to