Package org.mockserver.grpc.connect
Class ConnectResponse
java.lang.Object
org.mockserver.grpc.connect.ConnectResponse
Convenience factory for Connect protocol (buf.build Connect) unary responses.
Connect unary RPCs are ordinary HTTP POSTs to /package.Service/Method carrying the request
message directly (JSON or proto, not gRPC length-prefixed framing). Because they are plain
HTTP, MockServer's normal expectation matching already handles them — a user can mock a Connect
unary call with a standard httpRequest/httpResponse expectation. These helpers exist
only for convenience and correctness:
success(String)sets theapplication/jsoncontent type expected by Connect clients on a 200 response whose body is the response message directly.error(ConnectError)builds the non-200 Connect error envelope ({"code","message","details"}) with the HTTP status mapped from the Connect error code per the Connect spec.
HttpResponse, so all existing response infrastructure (delays, headers, verification,
the dashboard, DTO serialization) works unchanged, and real gRPC (application/grpc) traffic
is completely unaffected.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic HttpResponseerror(ConnectError error) A Connect unary error response: a non-200 HTTP status mapped from the Connect error code, with a JSON body of the shape{"code","message","details"}andContent-Type: application/json.static HttpResponseerror(ConnectError.Code code, String message) Shorthand forerror(ConnectError)from aConnectError.Codeand message.static HttpResponseA successful Connect unary response: HTTP 200,Content-Type: application/json, body is the response message JSON directly (no envelope, no framing).static HttpResponseA successful Connect unary response with an explicit content type, e.g.
-
Field Details
-
CONNECT_JSON_CONTENT_TYPE
- See Also:
-
CONNECT_PROTO_CONTENT_TYPE
- See Also:
-
-
Method Details
-
success
A successful Connect unary response: HTTP 200,Content-Type: application/json, body is the response message JSON directly (no envelope, no framing). -
success
A successful Connect unary response with an explicit content type, e.g.CONNECT_PROTO_CONTENT_TYPE. The body is passed through verbatim. -
error
A Connect unary error response: a non-200 HTTP status mapped from the Connect error code, with a JSON body of the shape{"code","message","details"}andContent-Type: application/json. -
error
Shorthand forerror(ConnectError)from aConnectError.Codeand message.
-