MCPcopy
hub / github.com/connectrpc/connect-go / NewClientStreamHandlerSimple

Function NewClientStreamHandlerSimple

handler.go:175–191  ·  view source on GitHub ↗

NewClientStreamHandlerSimple constructs a [Handler] for a request-streaming procedure using the function signature associated with the "simple" generation option. This option eliminates the [Response] wrapper, and instead uses the context.Context to propagate information such as headers.

(
	procedure string,
	implementation func(context.Context, *ClientStream[Req]) (*Res, error),
	options ...HandlerOption,
)

Source from the content-addressed store, hash-verified

173// This option eliminates the [Response] wrapper, and instead uses the context.Context
174// to propagate information such as headers.
175func NewClientStreamHandlerSimple[Req, Res any](
176 procedure string,
177 implementation func(context.Context, *ClientStream[Req]) (*Res, error),
178 options ...HandlerOption,
179) *Handler {
180 return NewClientStreamHandler(
181 procedure,
182 func(ctx context.Context, stream *ClientStream[Req]) (*Response[Res], error) {
183 responseMsg, err := implementation(ctx, stream)
184 if err != nil {
185 return nil, err
186 }
187 return NewResponse(responseMsg), nil
188 },
189 options...,
190 )
191}
192
193// NewServerStreamHandler constructs a [Handler] for a server streaming procedure.
194func NewServerStreamHandler[Req, Res any](

Callers 3

TestDynamicHandlerFunction · 0.92
NewPingServiceHandlerFunction · 0.92
NewTestServiceHandlerFunction · 0.92

Calls 2

NewClientStreamHandlerFunction · 0.85
NewResponseFunction · 0.85

Tested by 1

TestDynamicHandlerFunction · 0.74