Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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`.