grpc/service/interceptors.go
Adphi 6e86120943
add server interface interceptors
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
2022-07-15 15:48:09 +02:00

21 lines
435 B
Go

package service
import (
"go.linka.cloud/grpc/interceptors"
"go.linka.cloud/grpc/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
}