allow to catch response headers

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2022-11-15 12:53:04 +03:00
parent 3591d02d42
commit 83b6567d3e
8 changed files with 103 additions and 16 deletions

View File

@@ -1,6 +1,8 @@
package main
import (
"fmt"
"google.golang.org/protobuf/compiler/protogen"
)
@@ -22,8 +24,10 @@ func (g *Generator) microGenerate(component string, plugin *protogen.Plugin, gen
gfile := plugin.NewGeneratedFile(gname, path)
gfile.P("// Code generated by protoc-gen-go-micro. DO NOT EDIT.")
gfile.P("// protoc-gen-go-micro version: " + versionComment)
gfile.P("// source: ", file.Proto.GetName())
gfile.P("// versions:")
gfile.P("// - protoc-gen-go-micro " + versionComment)
gfile.P("// - protoc ", protocVersion(plugin))
gfile.P("// source: ", file.Desc.Path())
gfile.P()
gfile.P("package ", file.GoPackageName)
gfile.P()
@@ -50,3 +54,15 @@ func (g *Generator) microGenerate(component string, plugin *protogen.Plugin, gen
return nil
}
func protocVersion(plugin *protogen.Plugin) string {
v := plugin.Request.GetCompilerVersion()
if v == nil {
return "(unknown)"
}
var suffix string
if s := v.GetSuffix(); s != "" {
suffix = "-" + s
}
return fmt.Sprintf("v%d.%d.%d%s", v.GetMajor(), v.GetMinor(), v.GetPatch(), suffix)
}