mirror of
https://github.com/linka-cloud/grpc.git
synced 2024-11-25 20:36:24 +00:00
21 lines
451 B
Go
21 lines
451 B
Go
package service
|
|
|
|
import (
|
|
"go.linka.cloud/grpc-toolkit/interceptors"
|
|
"go.linka.cloud/grpc-toolkit/interceptors/metadata"
|
|
)
|
|
|
|
func md(opts *options) interceptors.Interceptors {
|
|
var pairs []string
|
|
if opts.name != "" {
|
|
pairs = append(pairs, "grpc-service-name", opts.name)
|
|
}
|
|
if opts.version != "" {
|
|
pairs = append(pairs, "grpc-service-version", opts.version)
|
|
}
|
|
if len(pairs) != 0 {
|
|
return metadata.NewInterceptors(pairs...)
|
|
}
|
|
return nil
|
|
}
|