All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ch.viascom.hipchat.api.interceptors.MethodNotAllowedCodeInterceptor Maven / Gradle / Ivy

There is a newer version: 2.1-RC3
Show newest version
package ch.viascom.hipchat.api.interceptors;

import ch.viascom.groundwork.foxhttp.exception.FoxHttpException;
import ch.viascom.groundwork.foxhttp.interceptor.response.FoxHttpResponseInterceptor;
import ch.viascom.groundwork.foxhttp.interceptor.response.context.FoxHttpResponseInterceptorContext;
import lombok.Getter;
import lombok.Setter;

import java.util.function.Consumer;


/**
 * @author [email protected]
 */
public class MethodNotAllowedCodeInterceptor implements FoxHttpResponseInterceptor {

    @Getter
    @Setter
    private int weight = 500;

    private Consumer methodNotAllowedCodeCallback;

    public MethodNotAllowedCodeInterceptor(Consumer methodNotAllowedCodeCallback) {
        this.methodNotAllowedCodeCallback = methodNotAllowedCodeCallback;
    }

    @Override
    public void onIntercept(FoxHttpResponseInterceptorContext context) throws FoxHttpException {
        if (context.getResponseCode() == 405) {
            methodNotAllowedCodeCallback.accept(context);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy