MCPcopy
hub / github.com/grpc/grpc-go / chainUnaryServerInterceptors

Function chainUnaryServerInterceptors

server.go:1225–1243  ·  view source on GitHub ↗

chainUnaryServerInterceptors chains all unary server interceptors into one.

(s *Server)

Source from the content-addressed store, hash-verified

1223
1224// chainUnaryServerInterceptors chains all unary server interceptors into one.
1225func chainUnaryServerInterceptors(s *Server) {
1226 // Prepend opts.unaryInt to the chaining interceptors if it exists, since unaryInt will
1227 // be executed before any other chained interceptors.
1228 interceptors := s.opts.chainUnaryInts
1229 if s.opts.unaryInt != nil {
1230 interceptors = append([]UnaryServerInterceptor{s.opts.unaryInt}, s.opts.chainUnaryInts...)
1231 }
1232
1233 var chainedInt UnaryServerInterceptor
1234 if len(interceptors) == 0 {
1235 chainedInt = nil
1236 } else if len(interceptors) == 1 {
1237 chainedInt = interceptors[0]
1238 } else {
1239 chainedInt = chainUnaryInterceptors(interceptors)
1240 }
1241
1242 s.opts.unaryInt = chainedInt
1243}
1244
1245func chainUnaryInterceptors(interceptors []UnaryServerInterceptor) UnaryServerInterceptor {
1246 return func(ctx context.Context, req any, info *UnaryServerInfo, handler UnaryHandler) (any, error) {

Callers 1

NewServerFunction · 0.85

Calls 1

chainUnaryInterceptorsFunction · 0.85

Tested by

no test coverage detected