<commit_before># Warning header for Spring Web MVC

[![Build Status](https://img.shields.io/travis/kakawait/spring-response-warning/master.svg?style=flat)](https://travis-ci.org/kakawait/spring-response-warning)
[![Coverage Status](https://img.shields.io/coveralls/kakawait/spring-response-warning/master.svg?style=flat)](https://coveralls.io/github/kakawait/spring-response-warning?branch=master)
[![license](https://img.shields.io/github/license/kakawait/spring-response-warning.svg?style=flat)](LICENSE)
[![Issues](https://img.shields.io/github/issues/kakawait/spring-response-warning/master.svg?style=flat)](https://github.com/kakawait/spring-response-warning/issues)


*Spring Warning Response* is a library that makes it easy to return
`Warning` header describes on [RFC7234](https://tools.ietf.org/html/rfc7234#section-5.5) responses from a Spring
application.

This library works around a single annotation `@ResponseWarning` that you can put over every controller methods.

## Installation

Add the following dependency to your project:

```xml
<dependency>
    <groupId>com.kakawait</groupId>
    <artifactId>spring-response-warning</artifactId>
    <version>${spring-response-warning.version}</version>
</dependency>
```

## Configuration

Nothing for *Spring-boot* application, *autoconfiguration* will do the jobs for you.

For other simply register `ResponseWarningHandlerInterceptor`

```java
@Configuration
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new ResponseWarningHandlerInterceptor());
    }
}
```

## Usage

Deprecating API sample:

```java
@RestController
class ProductsController {

    @ResponseWarning(
            warnCode = WarnCode.MISCELLANEOUS_PERSISTENT_WARNING, 
            text = "Deprecated API: use /{productId} instead.")
    @RequestMapping(method = GET, value = "/get", produces = APPLICATION_JSON_VALUE)
    @Deprecated
    public Product getProduct_v0(@RequestParam(value = "id") String productId) {
        return ...;
    }

    @RequestMapping(method = GET, value = "/{productId}", produces = APPLICATION_JSON_VALUE}
    public Product getProduct_v1(String productId) {<commit_msg>Fix README sample<commit_after># Warning header for Spring Web MVC

[![Build Status](https://img.shields.io/travis/kakawait/spring-response-warning/master.svg?style=flat)](https://travis-ci.org/kakawait/spring-response-warning)
[![Coverage Status](https://img.shields.io/coveralls/kakawait/spring-response-warning/master.svg?style=flat)](https://coveralls.io/github/kakawait/spring-response-warning?branch=master)
[![license](https://img.shields.io/github/license/kakawait/spring-response-warning.svg?style=flat)](LICENSE)
[![Issues](https://img.shields.io/github/issues/kakawait/spring-response-warning/master.svg?style=flat)](https://github.com/kakawait/spring-response-warning/issues)


*Spring Warning Response* is a library that makes it easy to return
`Warning` header describes on [RFC7234](https://tools.ietf.org/html/rfc7234#section-5.5) responses from a Spring
application.

This library works around a single annotation `@ResponseWarning` that you can put over every controller methods.

## Installation

Add the following dependency to your project:

```xml
<dependency>
    <groupId>com.kakawait</groupId>
    <artifactId>spring-response-warning</artifactId>
    <version>${spring-response-warning.version}</version>
</dependency>
```

## Configuration

Nothing for *Spring-boot* application, *autoconfiguration* will do the jobs for you.

For other simply register `ResponseWarningHandlerInterceptor`

```java
@Configuration
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new ResponseWarningHandlerInterceptor());
    }
}
```

## Usage

Deprecating API sample:

```java
@RestController
class ProductsController {

    @ResponseWarning(
            code = WarnCode.MISCELLANEOUS_PERSISTENT_WARNING, 
            text = "Deprecated API: use /{productId} instead.")
    @RequestMapping(method = GET, value = "/get", produces = APPLICATION_JSON_VALUE)
    @Deprecated
    public Product getProduct_v0(@RequestParam(value = "id") String productId) {
        return ...;
    }

    @RequestMapping(method = GET, value = "/{productId}", produces = APPLICATION_JSON_VALUE}
    public Product getProduct_v1(String productId) {
{'fraction_non_alphanumeric': 0.1246684350132626, 'fraction_numerical': 0.005305039787798408, 'mean_word_length': 5.106612685560054, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3968630', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1316, 'n_words': 276}