programing tip

리소스와 엔드 포인트의 차이점은 무엇입니까?

itbloger 2020. 7. 20. 07:47
반응형

리소스와 엔드 포인트의 차이점은 무엇입니까?


나는 "자원"과 "종료점"모두 같은 것을 말하는 것을 들었다. 자원은 더 새로운 용어 인 것 같습니다.

그들 사이의 차이점은 무엇입니까? "자원"이 RESTful 디자인을 의미합니까?


쉬다

ResourceEndpoint 의 RESTful 하위 집합입니다 .

엔드 포인트 자체로는 서비스가 액세스 할 수있는 위치입니다 :

https://www.google.com    # Serves HTML
8.8.8.8                   # Serves DNS
/services/service.asmx    # Serves an ASP.NET Web Service

자원 이 이해하기 인간에 대한 쉽기 때문에 하나 이상의 명사가, 네임 스페이스 방식으로 표현, 제공되는에 말한다 :

/api/users/johnny         # Look up johnny from a users collection.
/v2/books/1234            # Get book with ID 1234 in API v2 schema.

위의 모든 사항은 서비스 엔드 포인트로 간주 될 수 있지만 최하위 그룹 만 리소스로 간주되며 RESTful하게 말할 수 있습니다. 최상위 그룹은 제공하는 콘텐츠와 관련하여 표현력이 없습니다.

REST 요청은 명사 (자원)와 동사 (HTTP 메소드) 로 구성된 문장 같습니다.

  • GET(방법) 사용자 이름이 johnny(자원)입니다.
  • DELETE(방법) 아이디가있는 책 1234(자원)

비 REST

엔드 포인트는 일반적으로 서비스를 의미하지만 리소스는 많은 것을 의미 할 수 있습니다. 사용되는 컨텍스트에 따라 달라지는 리소스의 예는 다음과 같습니다.

URL : 균일 한 "자원"로케이터

  • RESTful 일 수 있지만 종종 그렇지 않습니다. 이 경우 엔드 포인트는 거의 동의어입니다.

자원 관리

사전

  • 정의는 단어의 더 많은 사용을 제공합니다.

당신을 도울 수있는 것 :

도서관은 귀중한 자료였으며 종종 그것을 활용했습니다.

자원은 생명을 유지하는 데 유용한 물과 나무와 같은 천연 물질입니다.

[pl] 지구는 자원이 제한되어 있으며, 재활용하지 않으면 재활용합니다.

자원은 또한 필요할 때 사용할 수있는 돈이나 소유물과 같은 가치있는 것들입니다.

[pl] 정부는 필요한 교사 수를 고용 할 자원이 없습니다.


도덕

정의에 의한 자원 이라는 용어 는 많은 미묘한 차이가 있습니다. 그것은 모두 사용 된 컨텍스트 에 달려 있습니다.


자원엔드 포인트 라는 용어 는 종종 동의어로 사용됩니다. 그러나 실제로 그들은 같은 것을 의미하지 않습니다.

엔드 포인트 라는 용어 는 요청하는 데 사용되는 URL에 중점을 둡니다 . 리소스
라는 용어 는 요청에 의해 반환되는 데이터 세트 에 중점을 둡니다 .

이제 여러 다른 엔드 포인트 에서 동일한 자원에 액세스 할 수 있습니다 . 또한 쿼리 문자열에 따라 동일한 끝 점이 다른 리소스를 반환 할 수 있습니다 .

몇 가지 예를 보자.

동일한 자원에 액세스하는 다른 엔드 포인트

다른 엔드 포인트 의 다음 예를 살펴보십시오 .

/api/companies/5/employees/3
/api/v2/companies/5/employees/3
/api/employees/3

그들은 분명히 주어진 API에서 모두 동일한 리소스액세스 할 수 있습니다 .

또한 기존 API를 완전히 변경할 수 있습니다. 이는 완전히 새롭고 다른 URL을 사용하여 동일한 이전 자원에 ​​액세스하는 새 엔드 포인트로 이어질 수 있습니다.

/api/employees/3
/new_api/staff/3

다른 리소스에 액세스하는 하나의 엔드 포인트

엔드 포인트가 콜렉션을 리턴하면 쿼리 문자열을 사용하여 검색 / 필터링 / 정렬을 구현할 수 있습니다. 결과적으로 다음 URL은 모두 동일한 엔드 포인트 ( /api/companies)를 사용하지만 다른 자원 (또는 자원 콜렉션 은 정의 자체로 자원 임)을 리턴 할 수 있습니다 .

/api/companies
/api/companies?sort=name_asc
/api/companies?location=germany
/api/companies?search=siemens

아마도 내 것이 큰 대답은 아니지만 여기에 간다.

Since working more with truly RESTful web services over HTTP, I've tried to steer people away from using the term endpoint since it has no clear definition, and instead use the language of REST which is resources and resource locations.

To my mind, endpoint is a TCP term. It's conflated with HTTP because part of the URL identifies a listening server.

So resource isn't a newer term, I don't think, I think endpoint was always misappropriated and we're realising that as we're getting our heads around REST as a style of API.

Edit

I blogged about this.

https://medium.com/@lukepuplett/stop-saying-endpoints-92c19e33e819


According https://apiblueprint.org/documentation/examples/13-named-endpoints.html is a resource a "general" place of storage of the given entity - e.g. /customers/30654/orders, whereas an endpoint is the concrete action (HTTP Method) over the given resource. So one resource can have multiple endpoints.


Consider a server which has the information of users, missions and their reward points.

  1. Users and Reward Points are the resources
  2. An end point can relate to more than one resource
  3. Endpoints can be described using either a description or a full or partial URL

enter image description here

Source: API Endpoints vs Resources


1. Resource description “Resources” refers to the information returned by an API.

2. Endpoints and methods The endpoints indicate how you access the resource, while the method indicates the allowed interactions (such as GET, POST, or DELETE) with the resource.

Additional info: 3. Parameters Parameters are options you can pass with the endpoint (such as specifying the response format or the amount returned) to influence the response.

4. Request example The request example includes a sample request using the endpoint, showing some parameters configured.

5. Response example and schema The response example shows a sample response from the request example; the response schema defines all possible elements in the response.

Source- Reference link

참고URL : https://stackoverflow.com/questions/30580562/what-is-the-difference-between-resource-and-endpoint

반응형