簡単な質問です。ベスト プラクティスの観点から、URL を次のようにフォーマットする方がよいでしょうか。
http://www.example.com/search?query=hello&page=1
またはこのように:
http://www.example.com/search/hello/page/1
選んだ正当な理由を教えてください。
簡単な質問です。ベスト プラクティスの観点から、URL を次のようにフォーマットする方がよいでしょうか。
http://www.example.com/search?query=hello&page=1
またはこのように:
http://www.example.com/search/hello/page/1
選んだ正当な理由を教えてください。
First one fits the situation where you want to "filter" your result if it gets a little too complicated, like this example:
cars.com/audi/sedan/a/4/black/manual.....
this is gonna take so long and complicated and result will be nightmare, but this would work better:
cars.com/mercedes/amg?color=white&transmission=manual
2nd way is just like thinking it of a 'folder'ed structure:
socialmedia.com/shares/1/comments/1/page/2
I am pretty sure you get the idea.
p.s. if you will provide your API to a brand new clients, who don't know anything about it, then first one is also more understandable but, i suggest you also have a API documentation which describes the parameters and the relevant poasible other calls as well. in this way your url formatting will be clearer and clients will not struggle to solve parameters in the url.
最初の方法は機能的であるだけでなく、人間が名前と値のペアが何であるかを理解できるようにします。確かに、構成と文字列操作を行って、URL を 2 番目の例のように見せても機能するようにすることもできますが、読みやすさと機能の容易さから、最初の例が最適です。