func UnaryCall(request *connectorpb.UnaryCallRequest) *connectorpb.UnaryCallResponse {
	if grpcServer == nil {
		return makeErrorResponse(codes.Unavailable, "call the initialize function first")
	}
	r, err := makeHTTPRequest(request)
	if err != nil {
		return makeErrorResponse(codes.Internal, "could not prepare an HTTP request")
	}
	w := &BodyWriter{
		header: make(http.Header),
	}
	grpcServer.ServeHTTP(w, r)
	grpcStatus := codes.Internal
	grpcMessage := "grpc-message field not found"
	for h, v := range w.header {
		if len(v) == 1 {
			if strings.ToLower(h) == "grpc-status" {
				i, err := strconv.Atoi(v[0])
				if err != nil {
					return makeErrorResponse(codes.Internal, "could not parse Grpc-Status header")
				}
				grpcStatus = codes.Code((i))
			}
			if strings.ToLower(h) == "grpc-message" {
				grpcMessage = v[0]
			}
		}
	}
	if grpcStatus != codes.OK {
		return makeErrorResponse(grpcStatus, grpcMessage)
	}
	lpm := w.b.Bytes()
	if len(lpm) < 5 {
		return makeErrorResponse(codes.Internal, "missing response body")
	}
	length := (int(lpm[1]) << 24) | (int(lpm[2]) << 16) | (int(lpm[3]) << 8) | int(lpm[4])
	if len(lpm) < 5+length {
		return makeErrorResponse(codes.Internal, "truncated response body")
	}
	return &connectorpb.UnaryCallResponse{
		Response: lpm[5:],
		Status: &statuspb.Status{
			Code:    int32(codes.OK),
			Message: grpcMessage,
		},
	}
}
UnaryCall directs the gRPC call from the client library to its handler. Requires a prior call to InitializeServer().
package main
import (
	"bytes"
	"io/ioutil"
	"net/http"
	"net/url"
	"strconv"
	"strings"
	statuspb "google.golang.org/genproto/googleapis/rpc/status"
	"google.golang.org/grpc"
	"google.golang.org/grpc/codes"
	conreg "github.com/GoogleCloudPlatform/declarative-resource-client-library/connector/server_registration"
	connectorpb "github.com/GoogleCloudPlatform/declarative-resource-client-library/python/proto/connector_go_proto"
)
const (
	CredentialsMetadataKey = "X-Call-Credentials"
	UserAgentMetadataKey = "User-Agent"
)
var grpcServer *grpc.Server
type BodyWriter struct {
	header http.Header
	b      bytes.Buffer
	code   int
}
func (b *BodyWriter) Header() http.Header {
	return b.header
}
func (b *BodyWriter) Write(data []byte) (int, error) {
	return b.b.Write(data)
}
func (b *BodyWriter) WriteHeader(statusCode int) {
	b.code = statusCode
}
func (b *BodyWriter) Flush() {}
func InitializeServer() *connectorpb.InitializeResponse {
	grpcServer = grpc.NewServer()
	return conreg.InitializeServer(grpcServer)
}