项目作者: spt-development

项目描述 :
Library for integrating spt-development/spt-development-cid into a web project.
高级语言: Java
项目地址: git://github.com/spt-development/spt-development-cid-web.git
创建时间: 2021-02-09T19:48:54Z
项目社区:https://github.com/spt-development/spt-development-cid-web

开源协议:Apache License 2.0

下载


  1. ____ ____ _____ ____ _ _
  2. / ___|| _ \_ _| | _ \ _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_
  3. \___ \| |_) || | | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __|
  4. ___) | __/ | | | |_| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_
  5. |____/|_| |_| |____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__|
  6. |_|
  7. cid-web-------------------------------------------------------------------------

build_status

Library for integrating spt-development/spt-development-cid
into a web project.

Usage

Register the CorrelationIdFilter to initialise the correlation ID for each incoming request and return as a response
header. For example, in a Spring based project register as a bean.

  1. @Bean
  2. public FilterRegistrationBean<CorrelationIdFilter> correlationIdFilter() {
  3. final FilterRegistrationBean<CorrelationIdFilter> filterRegBean = new FilterRegistrationBean<>(
  4. // Constructor overloads allow the overiding of the correlation ID header and whether to use the
  5. // request correlation ID header (if it exists) to initialise the correlation ID.
  6. new CorrelationIdFilter()
  7. );
  8. filterRegBean.setOrder(Ordered.HIGHEST_PRECEDENCE);
  9. filterRegBean.addUrlPatterns("/api/v1.0/*");
  10. return filterRegBean;
  11. }

Register the MdcCorrelationIdFilter to add the correlation ID to the MDC;

  1. @Bean
  2. public FilterRegistrationBean<MdcCorrelationIdFilter> mdcCorrelationIdFilter(@Value("${spt.cid.mdc.cid-key:#{null}}") String mdcCidKey) {
  3. final FilterRegistrationBean<MdcCorrelationIdFilter> filterRegBean = new FilterRegistrationBean<>(
  4. new MdcCorrelationIdFilter()
  5. );
  6. // This bean must be registed after the CorrelationIdFilter.
  7. filterRegBean.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);
  8. filterRegBean.addUrlPatterns("/api/v1.0/*");
  9. return filterRegBean;
  10. }

Alternatively, if you are integrating the library into a Spring Boot project, add the
spt-development/spt-development-cid-web-spring-boot
starter to your project’s pom.

Building locally

To build the library, run the following maven command:

  1. $ ./mvnw clean install

Release

To build a release and upload to Maven Central push to main.