I can't speak for most people, but IMO rest breaks down after a few years 
of API evolution.  RPC breaks down too, but to a lesser extent*.  

To answer your specific question, you can probably just double expose your 
API under two endpoints, since they will have different semantics and usage 
patterns.  Since you are splitting methods by nouns and verbs none of your 
URL paths should overlap.  You can delegate based on the initial request 
path to the correct gRPC or Rest handler.

*In case it matters I worked on a REST API for a while, and was 
occasionally bitten by REST semantics not being convenient.  Doing 
transactional updates in a REST model is pretty annoying.  Doing anything 
involving a non-idempotent mutation is annoying (like incrementing a view 
counter).   

On Tuesday, January 10, 2017 at 5:17:59 PM UTC-8, [email protected] 
wrote:
>
> I'm trying to design an API for our app. We're going to have to support a 
> REST API, but I'd really also like to have a gRPC API as well.
>
> The question is -- how to design them so they're roughly the same? And in 
> particular, what do we do about verbs / actions?
>
> The standard rule in designing a REST API is to use nouns, not verbs. This 
> blog post explains it well:
>
>
> https://apigee.com/about/blog/technology/restful-api-design-nouns-are-good-verbs-are-bad
>
> You should have http methods that look like this:
>
> GET /dogs/1234        // get a dog
> POST /dogs              // create a dog
> DELETE /dogs/1234  // delete a dog
>
> and not this:
>
> /createDog
> /deleteDog
>
> Unfortunately, gRPC makes standard REST-style calls impossible, because it 
> doesn't support path parameters, and as far as I can tell it always uses 
> the POST http method.
>
> So, I have two ways to modify the REST calls to make them gRPC compatible:
>
> 1. Put a verb in the endpoint:
>
> POST /dogs/create  body={ id: 1234, name="Fluffy" }
>
> or 2. Put the verb in the body:
>
> POST /dogs body={ action:"create", id: 1234, name="Fluffy" }
>
> What do most people do?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/bddc5e27-0f4d-4cd6-978b-1a6fc82ea724%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to