私はStudentsControllerを持っており、現在次の作業を行っています:
http://mycompany.com/api/v1/students <-- returns list of students
http://mycompany.com/api/v1/students/5 <-- returns student with Id = 5
2013 年のクラスのすべての学生を返す必要がありますが、もちろん以下は機能しません。
http://mycompany.com/api/v1/students/2013 <-- won't work, because it would look for the student with Id = 2013
私はこれを行うことができます:
http://mycompany.com/api/v1/students?gradclass=2013
しかし、次のようなクエリ文字列なしで意味のある方法があるかどうか疑問に思っています。
http://mycompany.com/api/v1/students/gradclasses/2013
上記のようなものは理にかなっていますが、これはあまり意味がありません:
http://mycompany.com/api/v1/students/gradclasses <-- this sort of makes no sense
また、ルーティングを使用して、適切なソリューションを見つけたら、どのようなアプローチでセットアップしますか?
これは価値がありますか?ベストプラクティスは何ですか? REST および GET クエリ パラメータのベスト プラクティスを見つけるのに苦労しています。