A Unary API
Important note
In terms of the underlying protocol, as we mentioned in Chapter 1, Networking Primer, the Unary API uses Send Header
followed by Send Message
and Half-Close
from the client side, and Send Message
plus Send Trailer
from the server side. If you need a refresher on these operations, I recommend you quickly check the RPC operations section in Chapter 1 of this book. This will help get a sense of what is going on when you are calling this API endpoint.
The easiest and most familiar API endpoint that you can write is a unary endpoint. These roughly translate to GET
, POST
, and other HTTP verbs that you probably worked with in REST APIs. You send a request and you get a response. Generally, these endpoints will be the ones that you use the most often to represent the treatment of one resource. For example, if you write a login method, you just need to send LoginRequest
and receive LoginResponse
.
For this section, we are going to write an RPC endpoint called...