@Override public void apply(final RequestTemplate requestTemplate) { requestTemplate.header(CommonConstant.TX_TRANSACTION_GROUP, TxTransactionLocal.getInstance().getTxGroupId()); }
public void apply(feign.RequestTemplate template) { final SpringCloudBeanRegistry beanRegistry = SpringCloudBeanRegistry.getInstance(); CompensableBeanFactory beanFactory = beanRegistry.getBeanFactory(); CompensableManager compensableManager = beanFactory.getCompensableManager(); CompensableTransaction compensable = compensableManager.getCompensableTransactionQuietly(); if (compensable == null) { return; } try { TransactionContext transactionContext = compensable.getTransactionContext(); byte[] byteArray = SerializeUtils.serializeObject(transactionContext); String transactionText = Base64.getEncoder().encodeToString(byteArray); Map<String, Collection<String>> headers = template.headers(); if (headers.containsKey(HEADER_TRANCACTION_KEY) == false) { template.header(HEADER_TRANCACTION_KEY, transactionText); } if (headers.containsKey(HEADER_PROPAGATION_KEY) == false) { template.header(HEADER_PROPAGATION_KEY, identifier); } } catch (IOException ex) { throw new RuntimeException("Error occurred while preparing the transaction context!", ex); } }
@Override public void apply(final RequestTemplate requestTemplate) { final MythTransactionContext mythTransactionContext = TransactionContextLocal.getInstance().get(); requestTemplate.header(CommonConstant.MYTH_TRANSACTION_CONTEXT, GsonUtils.getInstance().toJson(mythTransactionContext)); }
@Override public void apply(final RequestTemplate requestTemplate) { final HmilyTransactionContext hmilyTransactionContext = HmilyTransactionContextLocal.getInstance().get(); if (Objects.nonNull(hmilyTransactionContext)) { if (hmilyTransactionContext.getRole() == HmilyRoleEnum.LOCAL.getCode()) { hmilyTransactionContext.setRole(HmilyRoleEnum.INLINE.getCode()); } } requestTemplate.header(CommonConstant.HMILY_TRANSACTION_CONTEXT, GsonUtils.getInstance().toJson(hmilyTransactionContext)); }
LOG.info("{}={}", headerName, header); requestTemplate.header(headerName, header);
@Override public void apply(RequestTemplate input) { if (omegaContext!= null && omegaContext.globalTxId() != null) { input.header(GLOBAL_TX_ID_KEY, omegaContext.globalTxId()); input.header(LOCAL_TX_ID_KEY, omegaContext.localTxId()); LOG.debug("Added {} {} and {} {} to request header", GLOBAL_TX_ID_KEY, omegaContext.globalTxId(), LOCAL_TX_ID_KEY, omegaContext.localTxId()); } else { LOG.debug("Cannot inject transaction ID, as the OmegaContext is null or cannot get the globalTxId."); } } }
@Override public void apply(RequestTemplate template) { template.header("Authorization", headerValue); } }
@Override public void apply(RequestTemplate template) { template.header("Authorization", headerValue); } }
@Override public void apply(RequestTemplate template) { if(accessToken!=null) { template.header(Constants.AUTH_HEADER_NAME, BEARER_CONSTANT + accessToken); } }
@Override public void apply(final RequestTemplate template) { if (requestInterceptor != null) { requestInterceptor.apply(template); } template.header(MetacatRequestContext.HEADER_KEY_USER_NAME, userName); template.header(MetacatRequestContext.HEADER_KEY_CLIENT_APP_NAME, clientAppName); template.header(MetacatRequestContext.HEADER_KEY_JOB_ID, jobId); template.header(MetacatRequestContext.HEADER_KEY_DATA_TYPE_CONTEXT, dataTypeContext); } };
/** * Create a template with the header of provided name and extracted extract * * @see RequestInterceptor#apply(RequestTemplate) */ @Override public void apply(RequestTemplate template) { template.header(header, extract(tokenType)); }
@Override public void apply(RequestTemplate requestTemplate) { OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails) SecurityContextHolder.getContext().getAuthentication().getDetails(); requestTemplate.header("Authorization", "bearer " + details.getTokenValue()); } };
@Override public void apply(RequestTemplate requestTemplate) { OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails) SecurityContextHolder.getContext().getAuthentication().getDetails(); requestTemplate.header("Authorization", "bearer " + details.getTokenValue()); } };
@Override public void apply(RequestTemplate requestTemplate) { OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails) SecurityContextHolder.getContext() .getAuthentication().getDetails(); requestTemplate.header("Authorization", "bearer " + details.getTokenValue()); } };
@Override public void apply(RequestTemplate requestTemplate) { OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails) SecurityContextHolder.getContext().getAuthentication().getDetails(); requestTemplate.header("Authorization", "bearer " + details.getTokenValue()); } };
@Override public void apply(RequestTemplate requestTemplate) { OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails) SecurityContextHolder.getContext().getAuthentication().getDetails(); requestTemplate.header("Authorization", "bearer " + details.getTokenValue()); } };
private void setLabel(RequestTemplate template) { if (HystrixRequestContext.isCurrentThreadInitialized()) { String label = RequestVariableHolder.LABEL.get(); if (label != null) { template.header(RequestVariableHolder.HEADER_LABEL, label); } } }
private void handleConsumesAnnotation(MethodMetadata data, Consumes consumes, String name) { String[] serverConsumes = consumes.value(); String clientProduces = serverConsumes.length == 0 ? null : emptyToNull(serverConsumes[0]); checkState(clientProduces != null, "Consumes.value() was empty on %s", name); data.template().header(CONTENT_TYPE, (String) null); // remove any previous consumes data.template().header(CONTENT_TYPE, clientProduces); }
@Override public Request apply(RequestTemplate input) { TokenIdAndPublicURL urlAndToken = lazyUrlAndToken.get(); if (input.url().indexOf("http") != 0) { input.insert(0, urlAndToken.publicURL); } input.header("X-Auth-Token", urlAndToken.tokenId); return input.request(); } }