Files
Jiaxin ShanandGitHub 401cbe7fd1 Enable gofmt and move goimports to linter job (#158)
* Enable gofmt and move related work to linter job

1. Introduce gofmt github action
2. Move goimports from build job to lint job
3. Run gofmt -s -w to simplify test codes and fix all lint issues in apiserver and cli projects

* Fix lint errors in apiserver

* Fix lint errors in cli

* Fix goimports error
2022-02-28 13:49:31 +08:00

23 lines
720 B
Go

package interceptor
import (
"context"
"google.golang.org/grpc"
"k8s.io/klog/v2"
)
// ApiServerInterceptor implements UnaryServerInterceptor that provides the common wrapping logic
// to be executed before and after all API handler calls, e.g. Logging, error handling.
// For more details, see https://github.com/grpc/grpc-go/blob/master/interceptor.go
func ApiServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
klog.Infof("%v handler starting", info.FullMethod)
resp, err = handler(ctx, req)
if err != nil {
// TODO: handle errors
klog.Warning(err)
}
klog.Infof("%v handler finished", info.FullMethod)
return
}