Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spt-development/spt-development-cid-web
Library for integrating spt-development/spt-development-cid into a web project.
https://github.com/spt-development/spt-development-cid-web
correlation microservices spring-web
Last synced: about 2 months ago
JSON representation
Library for integrating spt-development/spt-development-cid into a web project.
- Host: GitHub
- URL: https://github.com/spt-development/spt-development-cid-web
- Owner: spt-development
- License: apache-2.0
- Created: 2021-02-09T19:48:54.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-15T11:28:55.000Z (3 months ago)
- Last Synced: 2024-09-15T13:08:05.123Z (3 months ago)
- Topics: correlation, microservices, spring-web
- Language: Java
- Homepage: https://github.com/spt-development/spt-development-cid-web
- Size: 135 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
````
____ ____ _____ ____ _ _
/ ___|| _ \_ _| | _ \ _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_
\___ \| |_) || | | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __|
___) | __/ | | | |_| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_
|____/|_| |_| |____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__|
|_|
cid-web-------------------------------------------------------------------------
````[![build_status](https://github.com/spt-development/spt-development-cid-web/actions/workflows/build.yml/badge.svg)](https://github.com/spt-development/spt-development-cid-web/actions)
Library for integrating [spt-development/spt-development-cid](https://github.com/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.```java
@Bean
public FilterRegistrationBean correlationIdFilter() {
final FilterRegistrationBean filterRegBean = new FilterRegistrationBean<>(
// Constructor overloads allow the overiding of the correlation ID header and whether to use the
// request correlation ID header (if it exists) to initialise the correlation ID.
new CorrelationIdFilter()
);filterRegBean.setOrder(Ordered.HIGHEST_PRECEDENCE);
filterRegBean.addUrlPatterns("/api/v1.0/*");return filterRegBean;
}
```Register the `MdcCorrelationIdFilter` to add the correlation ID to the [MDC](https://logback.qos.ch/manual/mdc.html);
```java
@Bean
public FilterRegistrationBean mdcCorrelationIdFilter(@Value("${spt.cid.mdc.cid-key:#{null}}") String mdcCidKey) {
final FilterRegistrationBean filterRegBean = new FilterRegistrationBean<>(
new MdcCorrelationIdFilter()
);// This bean must be registed after the CorrelationIdFilter.
filterRegBean.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);
filterRegBean.addUrlPatterns("/api/v1.0/*");return filterRegBean;
}
```Alternatively, if you are integrating the library into a Spring Boot project, add the
[spt-development/spt-development-cid-web-spring-boot](https://github.com/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:
```shell
$ ./mvnw clean install
```Release
=======To build a release and upload to Maven Central push to `main`.