Skip to content

Naming convention? #475

Closed
Closed
@knweiss

Description

Is there a naming convention that maps HTTP methods + REST resource paths to gRPC procedure names?

I.e. how would you name the gRPC procedures of the following REST endpoints?

Method Resource Path Description
GET /users Get a list of all users
GET /users/42 Get a specific user id
GET /users/42/tickets Get all tickets of user id 42
GET /users/42/tickets/23 Get ticket id 23 of user id 42
POST /users Create a new user
POST /users/42/tickets Create new ticket for user id 42
PUT /users Bulk-update users
PUT /users/42 Update user id 42
PUT /users/42/tickets/23 Update ticket id 23 of user id 42
PATCH /users/42 Partially update user id 42
PATCH /users/42/tickets/23 Partially update ticket id 23 of user id 42
DELETE /users Delete all users
DELETE /users/42 Delete user id 42
DELETE /users/42/tickets/23 Delete ticket id 23 of user id 42

Here are some suggestions with alternatives...

GetAllUsers() or GetUsers() or ReadAllUsers() or ReadUsers()
GetUser(u) or ReadUser(u)
GetAllTicketsOfUser(u) or ReadAllTicketsOfUser(u)
GetTicketOfUser(t, u) or ReadTicketOfUser(t, u)
PostUser(u) or CreateUser(u)
PostTicketForUser(t, u) or CreateTicketForUser(t, u)
PutUsers(users) or BulkUpdateUsers(users) or UpdateUsers(users)
PutUser(u) or UpdateUser(u)
PutTicketForUser(t, u) or UpdateTicketOfUser(t,  u)
PatchUser(u) or ModifyUser(u)
PatchTicketOfUser(t, u) or ModifyTicketOfUser(t, u)
DeleteAllUsers() or DeleteUsers()
DeleteUser(u)
DeleteTicketOfUser(t, u)

I'm thinking about details like "All" in the procedure name, singular vs plural,
For vs Of, Get vs Read vs Retrieve, Update vs Modify, Delete vs Destroy, CRUD vs HTTP method names, etc. Any thoughts or preferences?

Of course the answer also depends on the programming language. I'm especially interested in Go.

Are the any conventions or best practices?

Maybe we can put the conclusion (together with rationales) into the FAQ?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions