mirror of
https://github.com/linka-cloud/grpc.git
synced 2025-06-22 17:22:26 +00:00
add server interface interceptors
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
20
service/interceptors.go
Normal file
20
service/interceptors.go
Normal file
@ -0,0 +1,20 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user