- java.lang.Object
-
- io.vertx.grpc.transcoding.MethodTranscodingOptions
-
@Unstable("Transcoding is in tech preview") public class MethodTranscodingOptions extends Object
Defines configuration options for transcoding HTTP requests to gRPC service calls. This interface provides the necessary mapping information to translate between HTTP and gRPC, including path templates, HTTP methods, body mappings, and additional bindings. The transcoding options define how incoming HTTP requests should be mapped to gRPC method calls, including:- Which gRPC service/method to call (selector)
- What HTTP method and path pattern to match
- How to map the HTTP request/response bodies to gRPC messages
-
-
Constructor Summary
Constructors Constructor Description MethodTranscodingOptions()MethodTranscodingOptions(MethodTranscodingOptions that)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MethodTranscodingOptionsaddAdditionalBinding(MethodTranscodingOptions binding)Adds an additional binding.List<MethodTranscodingOptions>getAdditionalBindings()Gets additional HTTP bindings for the same gRPC method.StringgetBody()Gets the field path where the HTTP request body should be mapped in the gRPC request message.io.vertx.core.http.HttpMethodgetHttpMethod()Gets the HTTP method that this binding should match.StringgetPath()Gets the URL path template for this binding.StringgetResponseBody()Gets the field path in the gRPC response message to use as the HTTP response body.StringgetSelector()Gets the fully-qualified name of the gRPC method to be called.MethodTranscodingOptionssetBody(String body)Sets the field path where the HTTP request body should be mapped in the gRPC request message.MethodTranscodingOptionssetHttpMethod(io.vertx.core.http.HttpMethod httpMethod)Sets the HTTP method that this binding should match.MethodTranscodingOptionssetPath(String path)Sets the URL path template for this binding.MethodTranscodingOptionssetResponseBody(String responseBody)Sets the field path in the gRPC response message to use as the HTTP response body.MethodTranscodingOptionssetSelector(String selector)Set the fully-qualified name of the gRPC method to be called.
-
-
-
Constructor Detail
-
MethodTranscodingOptions
public MethodTranscodingOptions()
-
MethodTranscodingOptions
public MethodTranscodingOptions(MethodTranscodingOptions that)
-
-
Method Detail
-
getSelector
public String getSelector()
Gets the fully-qualified name of the gRPC method to be called.- Returns:
- The method selector string (e.g., "mypackage.MyService.MyMethod")
-
setSelector
public MethodTranscodingOptions setSelector(String selector)
Set the fully-qualified name of the gRPC method to be called.- Parameters:
selector- the gRPC method- Returns:
- this instance
-
getHttpMethod
public io.vertx.core.http.HttpMethod getHttpMethod()
Gets the HTTP method that this binding should match.- Returns:
- The HTTP method (GET, POST, etc.)
-
setHttpMethod
public MethodTranscodingOptions setHttpMethod(io.vertx.core.http.HttpMethod httpMethod)
Sets the HTTP method that this binding should match.- Parameters:
httpMethod- the HTTP method- Returns:
- this instance
-
getPath
public String getPath()
Gets the URL path template for this binding.- Returns:
- The path template string (e.g., "/v1/users/{user_id}")
-
setPath
public MethodTranscodingOptions setPath(String path)
Sets the URL path template for this binding.- Parameters:
path- the path- Returns:
- this instance
-
getBody
public String getBody()
Gets the field path where the HTTP request body should be mapped in the gRPC request message.- Returns:
- The body field path or null if no body mapping is needed
-
setBody
public MethodTranscodingOptions setBody(String body)
Sets the field path where the HTTP request body should be mapped in the gRPC request message.- Parameters:
body- the body- Returns:
- this instance
-
getResponseBody
public String getResponseBody()
Gets the field path in the gRPC response message to use as the HTTP response body.- Returns:
- The response body field path or null if no response body mapping is needed
-
setResponseBody
public MethodTranscodingOptions setResponseBody(String responseBody)
Sets the field path in the gRPC response message to use as the HTTP response body.- Parameters:
responseBody- the response doby- Returns:
- this instance
-
getAdditionalBindings
public List<MethodTranscodingOptions> getAdditionalBindings()
Gets additional HTTP bindings for the same gRPC method. This allows a single gRPC method to be exposed through multiple HTTP endpoints.- Returns:
- A list of additional bindings, or an empty list if none exist
-
addAdditionalBinding
public MethodTranscodingOptions addAdditionalBinding(MethodTranscodingOptions binding)
Adds an additional binding.- Parameters:
binding- the binding.- Returns:
- this instance
-
-