interceptor

package module
v0.0.0-...-ecc89d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2024 License: MIT Imports: 5 Imported by: 0

README

go-grpc-middleware-field-mask

Go grpc middleware for field mask

How to use

Pre-condition

You have to add field_mask into proto's request like

message Request{
  // main fields
  google.protobuf.FieldMask field_mask = 100;
}

  1. install via go get

go get github.com/linhbkhn95/go-grpc-middleware-field-mask `

  1. Import and inject into grpc interceptor The code in your application should be like that:
import(
        // ...
        "google.golang.org/grpc"
    	fieldmaskpkg "github.com/linhbkhn95/go-grpc-middleware-field-mask"


)
// ...

func main(){
    var unaryOpts []grpc.UnaryServerInterceptor{
		fieldmaskpkg.UnaryServerInterceptor(fieldmaskpkg.DefaultFilterFunc),
    }
    // Should append others interceptors
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnaryServerInterceptor

func UnaryServerInterceptor(filterFunc FilterFunc) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a new unary server interceptor that will decide whether to which fields should return to clients.

Types

type FilterFunc

type FilterFunc func(msg proto.Message, paths []string)
var DefaultFilterFunc FilterFunc = func(msg proto.Message, paths []string) {
	fmutils.Filter(msg, paths)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL