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, )
| 173 | // This option eliminates the [Response] wrapper, and instead uses the context.Context |
| 174 | // to propagate information such as headers. |
| 175 | func 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. |
| 194 | func NewServerStreamHandler[Req, Res any]( |