...

Source file src/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/server/non_standard_names.go

Documentation: github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/server

     1  package server
     2  
     3  import (
     4  	"context"
     5  
     6  	examples "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"
     7  	"google.golang.org/grpc/grpclog"
     8  )
     9  
    10  // Implements NonStandardServiceServer
    11  
    12  type nonStandardServer struct{}
    13  
    14  func newNonStandardServer() examples.NonStandardServiceServer {
    15  	return new(nonStandardServer)
    16  }
    17  
    18  func (s *nonStandardServer) Update(ctx context.Context, msg *examples.NonStandardUpdateRequest) (*examples.NonStandardMessage, error) {
    19  	grpclog.Info(msg)
    20  
    21  	newMsg := &examples.NonStandardMessage{
    22  		Thing: &examples.NonStandardMessage_Thing{SubThing: &examples.NonStandardMessage_Thing_SubThing{}}, // The fieldmask_helper doesn't generate nested structs if they are nil
    23  	}
    24  	applyFieldMask(newMsg, msg.Body, msg.UpdateMask)
    25  
    26  	grpclog.Info(newMsg)
    27  	return newMsg, nil
    28  }
    29  
    30  func (s *nonStandardServer) UpdateWithJSONNames(ctx context.Context, msg *examples.NonStandardWithJSONNamesUpdateRequest) (*examples.NonStandardMessageWithJSONNames, error) {
    31  	grpclog.Info(msg)
    32  
    33  	newMsg := &examples.NonStandardMessageWithJSONNames{
    34  		Thing: &examples.NonStandardMessageWithJSONNames_Thing{SubThing: &examples.NonStandardMessageWithJSONNames_Thing_SubThing{}}, // The fieldmask_helper doesn't generate nested structs if they are nil
    35  	}
    36  	applyFieldMask(newMsg, msg.Body, msg.UpdateMask)
    37  
    38  	grpclog.Info(newMsg)
    39  	return newMsg, nil
    40  }
    41  

View as plain text