| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Package prpc (provisional RPC) implements an RPC client over HTTP 1.x. | 5 // Package prpc (provisional RPC) implements an RPC client over HTTP 1.x. |
| 6 // | 6 // |
| 7 // Like gRPC: | 7 // Like gRPC: |
| 8 // - services are defined in .proto files | 8 // - services are defined in .proto files |
| 9 // - service implementation does not depend on pRPC. | 9 // - service implementation does not depend on pRPC. |
| 10 // Unlike gRPC: | 10 // Unlike gRPC: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // //go:generate cproto | 24 // //go:generate cproto |
| 25 // | 25 // |
| 26 // Install cproto: | 26 // Install cproto: |
| 27 // go install github.com/luci/luci-go/tools/cmd/cproto | 27 // go install github.com/luci/luci-go/tools/cmd/cproto |
| 28 // | 28 // |
| 29 // Protocol | 29 // Protocol |
| 30 // | 30 // |
| 31 // This section describes the pRPC protocol. It is based on HTTP 1.x and employs | 31 // This section describes the pRPC protocol. It is based on HTTP 1.x and employs |
| 32 // gRPC codes. | 32 // gRPC codes. |
| 33 // | 33 // |
| 34 // A pRPC server MUST handle HTTP requests at `/prpc/{service}/{method}` path, | 34 // A pRPC server MUST handle HTTP POST requests at `/prpc/{service}/{method}`, |
| 35 // decode an input message from an HTTP request, | 35 // decode an input message from an HTTP request, |
| 36 // call the service method implementation and | 36 // call the service method implementation and |
| 37 // encode the returned output message or error to the HTTP response. | 37 // encode the returned output message or error to the HTTP response. |
| 38 // | 38 // |
| 39 // pRPC protocol defines three protocol buffer encodings and media types. | 39 // pRPC protocol defines three protocol buffer encodings and media types. |
| 40 // - Binary: "application/prpc; encoding=binary" | 40 // - Binary: "application/prpc; encoding=binary" |
| 41 // - JSON: "application/prpc; encoding=json" or "application/json" | 41 // - JSON: "application/prpc; encoding=json" or "application/json" |
| 42 // A response body MUST have `)]}'` prefix to avoid CSRF. | 42 // A response body MUST have `)]}'` prefix to avoid CSRF. |
| 43 // - Text: "application/prpc; encoding=text" | 43 // - Text: "application/prpc; encoding=text" |
| 44 // A pRPC server MUST support Binary and SHOULD support JSON and Text. | 44 // A pRPC server MUST support Binary and SHOULD support JSON and Text. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // A server SHOULD specify it. | 80 // A server SHOULD specify it. |
| 81 // If not specified, a client MUST treat it is as Binary. | 81 // If not specified, a client MUST treat it is as Binary. |
| 82 // - Any metadata returned by a service method implementation MUST go into | 82 // - Any metadata returned by a service method implementation MUST go into |
| 83 // http headers, unless metadata key starts with "X-Prpc-". | 83 // http headers, unless metadata key starts with "X-Prpc-". |
| 84 // | 84 // |
| 85 // A server MUST always specify "X-Prpc-Grpc-Code". | 85 // A server MUST always specify "X-Prpc-Grpc-Code". |
| 86 // The server SHOULD specify HTTP status corresponding to the gRPC code. | 86 // The server SHOULD specify HTTP status corresponding to the gRPC code. |
| 87 // | 87 // |
| 88 // If a service/method is not found, the server MUST respond with Unimplemented | 88 // If a service/method is not found, the server MUST respond with Unimplemented |
| 89 // gRPC code and SHOULD specify HTTP 501 status. | 89 // gRPC code and SHOULD specify HTTP 501 status. |
| 90 // | |
| 91 // If HTTP method is not POST, the server MUST respond with Unimplemented | |
| 92 // gRPC code and SHOULD specify HTTP 405 status. | |
| 93 package prpc | 90 package prpc |
| OLD | NEW |