between a Go struct and a SQL line. type Mapper interface { // Table returns metadata of a table that the struct corresponds to. Table() *Table // Values returns column values except for the PK. The order is as same as the Column() result. Values() []interface{} ... } // InsertStruct inserts a new entity. func InsertStruct(ctx context.Context, db Execer, mapper orm.Mapper) error { ... res, err := db.ExecContext(ctx, buf.String(), vals...) ... } 構造体からのSQLの組み立てと実行
開発者はAPIの実装方法を切り替える必要がある ◦ JSON APIはURIとJSONの構造を決め、それに応じ て実装 ◦ gRPCの場合は、Protocol Buffersを定義し、インター フェースを生成し、それに応じて実装 それぞれgRPCとJSON API用のコントローラーを用意する必要がある 単純に実装した場合の課題 port A port B gRPC用のコントローラー JSON API用のコントローラー 共通の処理 Proto Request JSON Request