RESTful URL Design 準則

要設計RESTful URL,有一些準則可以參考,以下列出一些我覺得比較重要的部分,剩下的可以參考相關閱讀的兩篇文章,寫的都不錯。
  • Short
  • Lowercase, without mix-cases
  • Use plural path for collections, ex : /cars for all cars
  • Put individual resource under plural path. ex: /cars/car-1 or /cars/1
  • Use URL parameters ONLY with form-driven queries. ex: /cars/car/1, NOT /cars/car?id=1
  • Readable, Hierarchical, Simple.
  • Meaningful, ex: /cars/toyota/cr-z, NOT /cars/brand1/1
  • Hackable URL, ex: /cars/toyota/cr-z should have /cars/toyota/ and /cars
【相關閱讀】
Common REST Design Pattern
REST-ful URI design | RedRata

Share this post!

Bookmark and Share

0 意見: