func NewChainedServerInterceptor(interceptors ...ServerInterceptor) ServerInterceptor {
	switch n := len(interceptors); n {
	case 0:
		return nil
	case 1:
		return interceptors[0]
	default:
		return ServerInterceptorFunc(
			func(
				ctx context.Context,
				request interface{},
				serverInfo *ServerInfo,
				serverHandler ServerHandler,
			) (_ interface{}, retErr error) {
				chainer := func(
					currentInterceptor ServerInterceptor,
					currentHandler ServerHandler,
				) ServerHandler {
					return ServerHandlerFunc(
						func(
							currentCtx context.Context,
							currentRequest interface{},
						) (interface{}, error) {
							return currentInterceptor.Intercept(currentCtx, currentRequest, serverInfo, currentHandler)
						},
					)
				}
				chainedHandler := serverHandler
				for i := n - 1; i >= 0; i-- {
					chainedHandler = chainer(interceptors[i], chainedHandler)
				}
				return chainedHandler.Handle(ctx, request)
			},
		)
	}
}
// NewChainedServerInterceptor returns a new chained ServerInterceptor.
//
// Returns nil if interceptors is empty.
NewChainedServerInterceptor returns a new chained ServerInterceptor.

Returns nil if interceptors is empty.
// NewChainedServerInterceptor returns a new chained ServerInterceptor . // // Returns nil if interceptors is empty .
func NewChainedServerInterceptor(interceptors ...ServerInterceptor) ServerInterceptor {
	switch n := len(interceptors); n {
	case 0:
		return nil
	case 1:
		return interceptors[0]
	default:
		return ServerInterceptorFunc(
			func(
				ctx context.Context,
				request interface{},
				serverInfo *ServerInfo,
				serverHandler ServerHandler,
			) (_ interface{}, retErr error) {
				chainer := func(
					currentInterceptor ServerInterceptor,
					currentHandler ServerHandler,
				) ServerHandler {
					return ServerHandlerFunc(
						func(
							currentCtx context.Context,
							currentRequest interface{},
						) (interface{}, error) {
							return currentInterceptor.Intercept(currentCtx, currentRequest, serverInfo, currentHandler)
						},
					)
				}
				chainedHandler := serverHandler
				for i := n - 1; i >= 0; i-- {
					chainedHandler = chainer(interceptors[i], chainedHandler)
				}
				return chainedHandler.Handle(ctx, request)
			},
		)
	}
}
func NewChainedServerInterceptor ( interceptors ... ServerInterceptor ) ServerInterceptor { switch n := len ( interceptors ) ; n { case 0 : return nil case 1 : return interceptors [ 0 ] default : return ServerInterceptorFunc ( func ( ctx context . Context , request interface { } , serverInfo * ServerInfo , serverHandler ServerHandler , ) ( _ interface { } , retErr error ) { chainer := func ( currentInterceptor ServerInterceptor , currentHandler ServerHandler , ) ServerHandler { return ServerHandlerFunc ( func ( currentCtx context . Context , currentRequest interface { } , ) ( interface { } , error ) { return currentInterceptor . Intercept ( currentCtx , currentRequest , serverInfo , currentHandler ) } , ) } chainedHandler := serverHandler for i := n - 1 ; i >= 0 ; i -- { chainedHandler = chainer ( interceptors [ i ] , chainedHandler ) } return chainedHandler . Handle ( ctx , request ) } , ) } }
NewChainedServerInterceptor returns a new chained ServerInterceptor.
NewChainedServerInterceptor returns a new chained ServerInterceptor .