Posts
REST Endpoints:
- GET
/posts : Retrieve all posts. Accepts filter in Query Param like https://jsonplaceholder.typicode.com/posts?userId=1
- GET
/posts/{id} : Retrieve a single post by ID.
- POST
/posts : Create a new post.
- PUT
/posts/{id} : Update a post by ID.
- DELETE
/posts/{id} : Delete a post by ID.
gRPC Service Definition:
service PostService {
rpc ListPosts(Filter) returns (PostList);
rpc GetPost(PostRequest) returns (Post);
rpc CreatePost(Post) returns (PostResponse);
rpc UpdatePost(Post) returns (PostResponse);
rpc DeletePost(PostRequest) returns (DeleteResponse);
}
Users
REST Endpoints:
- GET
/users : Retrieve all users. accepts queryparams like https://jsonplaceholder.typicode.com/users?id=1&id=2
- GET
/users/{id} : Retrieve a single user by ID.
- POST
/users : Create a new user.
- PUT
/users/{id} : Update a user by ID.
- DELETE
/users/{id} : Delete a user by ID.
gRPC Service Definition:
service UserService {
rpc ListUsers(Filter) returns (UserList);
rpc GetUser(UserRequest) returns (User);
rpc CreateUser(User) returns (UserResponse);
rpc PatchUser(PatchUserRequest) returns (UserResponse);
rpc DeleteUser(UserRequest) returns (DeleteResponse);
}
- Define Proto Files: Create
.proto files containing these service and message definitions.
- Implement Server Logic: Develop server-side handlers for each gRPC method.
- Testing: Ensure each gRPC method correctly maps to the expected functionality of the original REST API.
Posts
REST Endpoints:
/posts: Retrieve all posts. Accepts filter in Query Param like https://jsonplaceholder.typicode.com/posts?userId=1/posts/{id}: Retrieve a single post by ID./posts: Create a new post./posts/{id}: Update a post by ID./posts/{id}: Delete a post by ID.gRPC Service Definition:
Users
REST Endpoints:
/users: Retrieve all users. accepts queryparams like https://jsonplaceholder.typicode.com/users?id=1&id=2/users/{id}: Retrieve a single user by ID./users: Create a new user./users/{id}: Update a user by ID./users/{id}: Delete a user by ID.gRPC Service Definition:
.protofiles containing these service and message definitions.