简体   繁体   English

REST API URL /端点设计

[英]REST API URL/Endpoints design

I have a debate here about some REST API design, the case is: we have courses table and lectures table, course has many lectures, "lectures are instances from a course", however the debate is how we can get the lectures? 我在这里有一些关于REST API设计的辩论,情况是:我们有课程表和讲座表,课程有很多讲座,“讲座是课程的实例”,但是辩论是如何获得讲座的? /course/id/lectures OR /lectures/course_id OR we should let the 2 options available? / course / id / lectures或/ lectures / course_id还是我们应该让2个选项可用?

Thank you. 谢谢。

My first intuition would be that you have to ask for the lectures of a course with something like 我的第一个直觉是,您必须要求某门课程的讲课,例如

GET /root/courses/course1/lectures GET / root / courses / course1 / lectures

which would yield a list of links to the lectures assigned to that course. 这将产生指向分配给该课程的讲座的链接列表。 Then, you could query the details about those lectures with: 然后,您可以通过以下方式查询有关这些讲座的详细信息:

GET /root/lectures/lecture1 GET / root / lectures / lecture1

using the links looking like: /root/lectures/lecture1 etc. obtained from the first query. 使用从第一个查询获得的类似于/root/lectures/lecture1等的链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM