Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add abstraction of code generator implementation #78

Merged
merged 1 commit into from
Dec 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions protoc-gen-grpc-gateway/generator/generator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Package generator provides an abstract interface to code generators.
package generator

import (
"github.com/gengo/grpc-gateway/protoc-gen-grpc-gateway/descriptor"
plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
)

// Generator is an abstraction of code generators.
type Generator interface {
// Generate generates output files from input .proto files.
Generate(targets []*descriptor.File) ([]*plugin.CodeGeneratorResponse_File, error)
}
3 changes: 2 additions & 1 deletion protoc-gen-grpc-gateway/gengateway/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"

"github.com/gengo/grpc-gateway/protoc-gen-grpc-gateway/descriptor"
gen "github.com/gengo/grpc-gateway/protoc-gen-grpc-gateway/generator"
"github.com/golang/glog"
"github.com/golang/protobuf/proto"
plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
Expand All @@ -24,7 +25,7 @@ type generator struct {
}

// New returns a new generator which generates grpc gateway files.
func New(reg *descriptor.Registry) *generator {
func New(reg *descriptor.Registry) gen.Generator {
var imports []descriptor.GoPackage
for _, pkgpath := range []string{
"encoding/json",
Expand Down