REST api design to retrieve summary information
-
23-09-2019 - |
문제
I have a scenario in which I have REST API which manages a Resource which we will call Group. A Group is similar in concept to a discussion forum in Google Groups.
Now I have two GET access method which I believe needs separate representations.
The 1st GET access method retrieves the minimal amount of information about a Group. Given a group_id it should return a minimal amount of information like
{
group_id: "5t7yu8i9io0op",
group_name: "Android Developers",
is_moderated: true,
number_of_users: 34,
new_messages: 5,
icon: "http://boo.com/pic.png"
}
The 2nd GET access method retrives summary information which are more statistical in nature like:
{
group_id: "5t7yu8i9io0op",
top_ranking_users: {
[ { user: "george", posts: 789, rank: 1 },
{ user: "joel", posts: 560, rank: 2 } ...]
},
popular_topics: {
[ ... ]
}
}
I want to separate these data access methods and I'm currently planning on this design:
GET /group/:group_id/
GET /group/:group_id/stat
Only the latter will return the statistical information about the group. What do you think about this ?
해결책
여기를 여기에 크롤링하지 않도록 로봇에게 다음과 같은 두 가지 방법이 있습니다.
-
SharePoint Designer (SPD의 모든 항목)가있는 루트 폴더의 다음 콘텐츠가있는 robots.txt 추가
User-agent: * Disallow: /
-
아래와 같이 마스터 페이지의 머리 섹션에 메타 태그를 추가하면 로봇이 사이트를 집어 들지 못하게해야합니다.
<meta name="robots" content="noindex" >
나는 그것을 테스트하지 않았습니다. 이에비 로봇은이 메타 태그 설정을 존중하지 않습니다.
다음과 같이 귀하의 사이트를 군중으로 만족시키지 못하게하는 것도 확실합니다
.<meta name="googlebot" content="noindex">
Google 에서이 기사를 확인하십시오 https://support.google.com/webmasters/answer/93710?rd=.1
-
다른 팁
What would be even better would be if you embedded the link to the statistics in the group summary:
{
group_id: "5t7yu8i9io0op",
group_name: "Android Developers",
is_moderated: true,
number_of_users: 34,
new_messages: 5,
icon: "http://boo.com/pic.png"
stats_link : "http://whatever.who/cares"
}