Spring Response Warning

Controller annotation to add Warning header on response

Лицензия

Лицензия

Группа

Группа

com.kakawait
Идентификатор

Идентификатор

spring-response-warning
Последняя версия

Последняя версия

0.1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Spring Response Warning
Controller annotation to add Warning header on response
Ссылка на сайт

Ссылка на сайт

https://github.com/kakawait/spring-response-warning
Система контроля версий

Система контроля версий

https://github.com/kakawait/spring-response-warning

Скачать spring-response-warning

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.kakawait/spring-response-warning/ -->
<dependency>
    <groupId>com.kakawait</groupId>
    <artifactId>spring-response-warning</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.kakawait/spring-response-warning/
implementation 'com.kakawait:spring-response-warning:0.1.0'
// https://jarcasting.com/artifacts/com.kakawait/spring-response-warning/
implementation ("com.kakawait:spring-response-warning:0.1.0")
'com.kakawait:spring-response-warning:jar:0.1.0'
<dependency org="com.kakawait" name="spring-response-warning" rev="0.1.0">
  <artifact name="spring-response-warning" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.kakawait', module='spring-response-warning', version='0.1.0')
)
libraryDependencies += "com.kakawait" % "spring-response-warning" % "0.1.0"
[com.kakawait/spring-response-warning "0.1.0"]

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
org.springframework : spring-webmvc jar 4.2.6.RELEASE
org.springframework.boot : spring-boot-autoconfigure jar 1.3.5.RELEASE
javax.servlet : javax.servlet-api jar 3.1.0

test (4)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
org.assertj : assertj-core jar 3.4.1
org.springframework : spring-test jar 4.2.6.RELEASE
org.hamcrest : java-hamcrest jar 2.0.0.0

Модули Проекта

Данный проект не имеет модулей.

Warning header for Spring Web MVC

Build Status Issues Coverage Status License Maven Central GitHub release

Spring Warning Response is a library that makes it easy to return Warning header describes on RFC7234 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:

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

Configuration

With Spring-boot (autoconfiguration)

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

Without Spring-boot

Simply register ResponseWarningHandlerInterceptor

@Configuration
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {

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

Usage

Deprecating API sample:

@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) {
        return ...;
    }

}

The following HTTP request will produce the corresponding response:

GET /products?id=123 HTTP/1.1
HTTP/1.1 200 Ok
Content-Type: application/json
Warning: 299 - "Deprecated API: use /{productId} instead." 

...

Getting help

If you have questions, concerns, bug reports, etc., please file an issue in this repository's Issue Tracker.

Getting involved

To contribute, simply make a pull request and add a brief description (1-2 sentences) of your addition or change.

Credits and references

Версии библиотеки

Версия
0.1.0