|
@@ -0,0 +1,27 @@
|
|
|
+package middleware
|
|
|
+
|
|
|
+import (
|
|
|
+ "github.com/grpc-ecosystem/go-grpc-middleware"
|
|
|
+ "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
|
|
|
+ "github.com/grpc-ecosystem/go-grpc-middleware/tags"
|
|
|
+ "github.com/grpc-ecosystem/go-grpc-middleware/validator"
|
|
|
+ "google.golang.org/grpc"
|
|
|
+)
|
|
|
+
|
|
|
+func GetStreamMiddleware() grpc.ServerOption {
|
|
|
+ return grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(
|
|
|
+ grpc_ctxtags.StreamServerInterceptor(),
|
|
|
+ grpc_validator.StreamServerInterceptor(),
|
|
|
+ StreamServerFsLogInterceptor(),
|
|
|
+ grpc_recovery.StreamServerInterceptor(),
|
|
|
+ ))
|
|
|
+}
|
|
|
+
|
|
|
+func GetUnaryMiddleware() grpc.ServerOption {
|
|
|
+ return grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
|
|
|
+ grpc_ctxtags.UnaryServerInterceptor(),
|
|
|
+ grpc_validator.UnaryServerInterceptor(),
|
|
|
+ UnaryServerFsLogInterceptor(),
|
|
|
+ grpc_recovery.UnaryServerInterceptor(),
|
|
|
+ ))
|
|
|
+}
|