Skip to content

Commit

Permalink
Merge pull request #123 from bianjieai/ori/key_header
Browse files Browse the repository at this point in the history
add key 'x-api-key' to header
  • Loading branch information
prolenking authored Jun 25, 2023
2 parents e06696a + 5873588 commit 0d0cb15
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/irita/sdk/client/GrpcBSNInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class GrpcBSNInterceptor implements ClientInterceptor {
private final OpbConfig opbConfig;
private final Metadata.Key<String> PROJECT_ID_HEADER = Metadata.Key.of("projectIdHeader", Metadata.ASCII_STRING_MARSHALLER);
private final Metadata.Key<String> PROJECT_KEY_HEADER = Metadata.Key.of("projectKeyHeader", Metadata.ASCII_STRING_MARSHALLER);
private final Metadata.Key<String> API_PROJECT_KEY_HEADER = Metadata.Key.of("x-api-key", Metadata.ASCII_STRING_MARSHALLER);
private final Metadata.Key<String> CHAIN_ACCOUNT_ADDRESS_HEADER = Metadata.Key.of("chainAccountAddressHeader", Metadata.ASCII_STRING_MARSHALLER);

public GrpcBSNInterceptor(OpbConfig opbConfig) {
Expand All @@ -23,6 +24,7 @@ public void start(Listener<RespT> responseListener, Metadata headers) {
if (opbConfig != null) {
headers.put(PROJECT_ID_HEADER, Optional.ofNullable(opbConfig.getProjectID()).orElse(""));
headers.put(PROJECT_KEY_HEADER, Optional.ofNullable(opbConfig.getProjectKey()).orElse(""));
headers.put(API_PROJECT_KEY_HEADER, Optional.ofNullable(opbConfig.getProjectKey()).orElse(""));
headers.put(CHAIN_ACCOUNT_ADDRESS_HEADER, Optional.ofNullable(opbConfig.getChainAccountAddr()).orElse(""));
if (opbConfig.getHeader() != null){
for (String key : opbConfig.getHeader().keySet()){
Expand Down

0 comments on commit 0d0cb15

Please sign in to comment.