What are the best RESTful methods when defining a query parameter with a condition or?

I would like to know, following the RESTful best practices, how I should define the URL as follows:

/people?q="email=aa@aa.com||phone=11111"

The bottom line is to search for a person by their email address or phone, depending on what they have inserted in the search field.

I read a few guides on best practices for using RESTful services, but no one talks about this situation.

+4
source share
3 answers

REST means you follow the standards by creating a (unified) application interface.

GET. URL, . . RQL, OData, REST API URI: mongodb .. . , . , . SPARQL, REST RDF vocabs hydra. , MIME . ( , , .)

, URI, - RDF MIME . , , / , HATEOAS wikipedia. ( - , , URI.)

, , SQL - .

+3

:

/people?condition=OR&email=aa@aa.com&phone=11111

/URL- .

+1

An alternative could be:

/people?or_email=aa@aa.com&or_phone=11111

Thus, you can also search by mail and phone.

/people?and_email=aa@aa.com&and_phone=11111

or even perform more complex queries, for example:

/people?and_email=aa@aa.com&and_phone=11111&or_name=Alice
0
source

Source: https://habr.com/ru/post/1611926/


All Articles