incognitjoe / spring-clacks-overhead

A man is not dead while his name is still spoken.

Repository from Github https://github.comincognitjoe/spring-clacks-overheadRepository from Github https://github.comincognitjoe/spring-clacks-overhead

X-Clacks-Overhead: GNU Terry Pratchett

An example Spring interceptor for adding GNU Terry Pratchett headers to HTTP responses.

Usage

Interceptors must be registered before they're applied. The following configuration class in a Spring Boot project would do the trick:

import org.incognitjoe.clacks.interceptors.ClacksOverheadInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@Import(ClacksOverheadInterceptor.class)
public class RestConfig implements WebMvcConfigurer {

    @Autowired
    private ClacksOverheadInterceptor clacksOverheadInterceptor;

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

About

A man is not dead while his name is still spoken.


Languages

Language:Java 100.0%