annotation: Add support for multiple HTTP operations
RussellLuo opened this issue · 0 comments
RussellLuo commented
Sometimes, a Go method needs to correspond to more than one URI (or HTTP method). For example:
type Service interface {
//kun:op GET /messages/{messageID}
//kun:op GET /users/{userID}/messages/{messageID}
GetMessage(ctx context.Context, userID string, messageID string) (text string, err error)
}
This will enable the following two alternative HTTP to Go-method mappings:
HTTP | Go Method |
---|---|
GET /messages/123456 | GetMessage(ctx, "", "123456") |
GET /users/me/messages/123456 | GetMessage(ctx, "me", "123456") |
This feature is much like (and is partially inspired by) gRPC's additional_bindings
option (also see Multiple URI bindings).