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

org.zalando.riptide.idempotency.DefaultIdempotencyDetector Maven / Gradle / Ivy

There is a newer version: 4.1.0
Show newest version
package org.zalando.riptide.idempotency;

import org.apiguardian.api.API;
import org.springframework.http.HttpMethod;
import org.zalando.riptide.RequestArguments;

import java.util.Set;

import static org.apiguardian.api.API.Status.EXPERIMENTAL;
import static org.springframework.http.HttpMethod.DELETE;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.http.HttpMethod.HEAD;
import static org.springframework.http.HttpMethod.OPTIONS;
import static org.springframework.http.HttpMethod.PUT;
import static org.springframework.http.HttpMethod.TRACE;

/**
 * @see Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content, Section 4.2.1
 * @see Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content, Section 4.2.2
 */
@API(status = EXPERIMENTAL)
public final class DefaultIdempotencyDetector implements IdempotencyDetector {
    private final Set ACCEPTED_METHODS = Set.of(DELETE, GET, HEAD, OPTIONS, PUT, TRACE);

    @Override
    public Decision test(final RequestArguments arguments, final Test root) {
        if (ACCEPTED_METHODS.contains(arguments.getMethod())) {
            return Decision.ACCEPT;
        }

        return Decision.NEUTRAL;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy