On Tue, Aug 30, 2016 at 12:52 PM, Shan Mahanama <[email protected]> wrote:

> Hi all,
>
> We are designing an API for search. We need to pass a regex as the search
> query.
>
> Sample API - /search/{query}
>
If we consider REST best practices usually we do use above URL pattern to
get resource when we know resource ID.
And search is not a resource in pure REST implementation. We can do
something like this.
applications/{application-id} > to get application when we know application
id

Normally search conditions pass as non mandatory query parameters.
applications?search=name:test
applications?search=regex

When you design/implement new REST APIs its better if we can design it
properly and review it completely before start implementation.
Also please follow REST API best practices guideline document we published.

Query - wso2.*
> URL Encoded Request - /search/wso2.%2A
>
> When we encode the regex and call the API, we get the following error
> message.
>
> <ams:message>No matching resource found in the API for the given
> request</ams:message>
>
> How can we solve this issue?
>
Back to your original question, In URL templates test case we do have
following. So technically this should works fine.

template = new URITemplate("/host/users/{id}");
//var.put("id", "23");
assertTrue(template.matches("/host/users/23", var));
assertTrue(template.matches("/host/users/23?active=true", var));

Did you tried this with REST API? If so what is the version?

Thanks,
sanjeewa.

>
> Thanks,
> Shan.
>
> --
> Shan Mahanama
>
> Software Engineer, WSO2 Inc. http://wso2.com
> <http://l.facebook.com/l.php?u=http%3A%2F%2Fwso2.com&h=gAQEswASa>
> Email: [email protected]
> Mobile: +94712000498
>
>
>


-- 

*Sanjeewa Malalgoda*
WSO2 Inc.
Mobile : +94713068779

<http://sanjeewamalalgoda.blogspot.com/>blog
:http://sanjeewamalalgoda.blogspot.com/
<http://sanjeewamalalgoda.blogspot.com/>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to