{"id":20762530,"url":"https://github.com/welllog/grpc_interceptor","last_synced_at":"2025-08-18T07:06:35.251Z","repository":{"id":57545032,"uuid":"297864099","full_name":"welllog/grpc_interceptor","owner":"welllog","description":"grpc interceptor","archived":false,"fork":false,"pushed_at":"2023-11-29T14:01:56.000Z","size":92,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-18T05:42:45.326Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/welllog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-23T05:37:21.000Z","updated_at":"2023-02-27T09:53:07.000Z","dependencies_parsed_at":"2024-06-20T18:54:55.254Z","dependency_job_id":"d3be5d19-652f-4187-87b8-1b361d7ee548","html_url":"https://github.com/welllog/grpc_interceptor","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welllog%2Fgrpc_interceptor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welllog%2Fgrpc_interceptor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welllog%2Fgrpc_interceptor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welllog%2Fgrpc_interceptor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/welllog","download_url":"https://codeload.github.com/welllog/grpc_interceptor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243079572,"owners_count":20233009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T10:35:56.706Z","updated_at":"2025-03-11T17:35:03.968Z","avatar_url":"https://github.com/welllog.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grpc_interceptor\n\ngrpc interceptor\n\n## usage\n\n##### server\n\n```go\nfunc ServerDemo1(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, \nhandler grpc.UnaryHandler) (interface{}, error) {\n\n    log.Printf(\"before handling. Info: %+v\", info)\n    resp, err := handler(ctx, req)\n    log.Printf(\"after handling. resp: %+v\", resp)\n    return rsp, err\n}\n\nfunc ServerDemo2(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo,\nhandler grpc.StreamHandler) error {\n\n    log.Printf(\"before handling. Info: %+v\", info)\n    err := handler(srv, ss)\n    log.Printf(\"after handling. err: %v\", err)\n    return err\n}\n\n...\n\n\n\n// Load interceptor ServerDemo1, ignore on /package.Service/Do1 method\n// Same set of interceptors using a common black list\nunaryServerIcpts := \u0026grpc_interceptor.UnaryServerInterceptors{}\nunaryServerIcpts.AddWithoutMethods(\n\t[]string{\"/package.Service/Do1\"},\n    ServerDemo1,\n)\n\n// Load interceptor ServerDemo2, ignore on /package.Service/Do2 method\nstreamServerIcpts := \u0026grpc_interceptor.StreamServerInterceptors{}\nstreamServerIcpts.AddWithoutMethods(\n\t[]string{\"/package.Service/Do2\"},\n\tServerDemo2,\n\t...\n)\n\n\ns := grpc.NewServer(\n        grpc.StreamInterceptor(streamServerIcpts.StreamServerInterceptor()),\n        grpc.UnaryInterceptor(unaryServerIcpts.UnaryServerInterceptor()),\n)\n```\n\n##### client\n```go\nfunc clientDemo1(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,\ninvoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {\n\n\tlog.Printf(\"before invoker. method: %+v, request:%+v\", method, req)\n\terr := invoker(ctx, method, req, reply, cc, opts...)\n\tlog.Printf(\"after invoker. reply: %+v\", reply)\n\treturn err\n}\n\nfunc clientDemo2(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, \nstreamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {\n\n\tlog.Printf(\"before invoker. method: %+v, StreamDesc:%+v\", method, desc)\n\tclientStream, err := streamer(ctx, desc, cc, method, opts...)\n\tlog.Printf(\"before invoker. method: %+v\", method)\n\treturn clientStream, err\n}\n\n...\n\n\nunaryClientIcpts := \u0026grpc_interceptor.UnaryClientInterceptors{}\nunaryClientIcpts.Add(\n    clientDemo1,\n    ...\n)\n\n// Load the interceptor clientDemo2 for /package.Service/Do2 methods only\nstreamClientIcpts := \u0026grpc_interceptor.StreamClientInterceptors{}\nstreamClientIcpts.AddOnMethods([]string{\"/package.Service/Do2\"}, clientDemo2)\n\ngrpc.Dial(*address, grpc.WithInsecure(), \n    grpc.WithUnaryInterceptor(unaryClientIcpts.UnaryClientInterceptor()), \n    grpc.WithStreamInterceptor(streamClientIcpts.StreamClientInterceptor()),\n)\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwelllog%2Fgrpc_interceptor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwelllog%2Fgrpc_interceptor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwelllog%2Fgrpc_interceptor/lists"}