서버 런타임 예시 #
서버 대 서버 #
클라이언트 호출과 달리 서버 간 호출에는 사용자 ID가 없으므로 클라이언트에서 액세스하지 못하게 하려는 함수의 경우 컨텍스트에서 사용자 ID가 발견되면 오류를 반환하면 됩니다.
Server
|
|
Server
|
|
Server
|
|
또한, 웹 서비스에서 사용할 수 있고 사용자 지정 서버 환경에 쉽게 통합할 수 있는 HTTP REST 핸들러를 만드는 것이 유용할 수 있습니다.
이렇게 하려면 RPC 후크와 런타임 HTTP 키를 사용하여 서버를 인증하면 됩니다:
Server
|
|
Server
|
|
Server
|
|
등록된 RPC 함수는 선택한 모든 HTTP 클라이언트로 호출할 수 있습니다. 예를 들어, cURL을 사용하면 다음과 같이 서버에서 이 함수를 실행할 수 있습니다.
|
|
JSON 페이로드가 이스케이프되고 문자열 내부에 래핑됩니다. 이는 RPC API가 설계된 시점에 Protobuf 유형과 JSON 객체 간에 매핑되는 유형이 gRPC에 없기 때문에 설계된 것입니다. 이후 JSON 지원이 gRPC에 추가되었지만 API 계약을 위반하지 않고 호환성을 보장하기 위해 이 방식이 유지되었습니다.
페이로드의 원시 JSON 데이터로 RPC 함수를 호출할 수 있는 unwrap
쿼리 매개변수가 지원됩니다:
|
|
사용자 초기화 #
등록이 완료된 후 새 사용자에 대한 레코드를 작성하는 사용자 등록 후크.
"register_after"
후크는 “authenticaterequest_*” 메시지 유형과 함께 사용하여 메시지가 처리된 후에 서버가 기능을 실행하도록 전달합니다. 서버에서는 등록과 로그인 메시지가 구분되지 않기 때문에 조건부 작성을 사용하여 레코드를 저장합니다.
Server
|
|
Server
|
|
Server
|
|
저장소 #
저장소에 쓰기 #
Server
|
|
Server
|
|
Server
|
|