com.scalar.dl.client.rpc.AuthorizationInterceptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scalardl-java-client-sdk Show documentation
Show all versions of scalardl-java-client-sdk Show documentation
A client-side Java library to interact with Scalar DL network.
The newest version!
package com.scalar.dl.client.rpc;
import io.grpc.CallOptions;
import io.grpc.Channel;
import io.grpc.ClientCall;
import io.grpc.ClientInterceptor;
import io.grpc.ForwardingClientCall;
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;
public class AuthorizationInterceptor implements ClientInterceptor {
private static final String KEY = "authorization";
private final String token;
public AuthorizationInterceptor(String token) {
this.token = token;
}
@Override
public ClientCall interceptCall(
MethodDescriptor methodDescriptor, CallOptions callOptions, Channel channel) {
return new ForwardingClientCall.SimpleForwardingClientCall(
channel.newCall(methodDescriptor, callOptions)) {
@Override
public void start(Listener responseListener, Metadata headers) {
headers.put(Metadata.Key.of(KEY, Metadata.ASCII_STRING_MARSHALLER), token);
super.start(responseListener, headers);
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy