-
Notifications
You must be signed in to change notification settings - Fork 791
Closed
Labels
Description
Hi,
is it possible to write a custom interceptor?
Can i access the custom metadata?
In kotlin i do something like this:
CustomInterceptor : ServerInterceptor{
private var codeKey: Metadata.Key<Int> = Metadata.Key.of("meta1", IntMarshaller())
private var messageKey: Metadata.Key<String> = Metadata.Key.of("meta2", UTF8Marshaller())
override fun <ReqT : Any?, RespT : Any?> interceptCall(call: ServerCall<ReqT, RespT>?, headers: Metadata?, next: ServerCallHandler<ReqT, RespT>?): ServerCall.Listener<ReqT> {
val delegate = next!!.startCall(call, headers)
return object : SimpleForwardingServerCallListener<ReqT>(delegate) {
override fun onHalfClose() {
call?.close(Status.UNKNOWN, customMetadata)
}
}
}
}}
jevonearth, MyCADDev, danimt, longfellowone, xgenvn and 3 moreclehene