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

com.artipie.http.rt.RtRulePath Maven / Gradle / Ivy

There is a newer version: v1.17.16
Show newest version
/*
 * The MIT License (MIT) Copyright (c) 2020-2023 artipie.com
 * https://github.com/artipie/artipie/blob/master/LICENSE.txt
 */
package com.artipie.http.rt;

import com.artipie.http.Response;
import com.artipie.http.Slice;
import java.nio.ByteBuffer;
import java.util.Map;
import java.util.Optional;
import org.reactivestreams.Publisher;

/**
 * Rule-based route path.
 * 

* A path to slice with routing rule. If * {@link RtRule} passed, then the request will be redirected to * underlying {@link Slice}. *

* @since 0.10 */ public final class RtRulePath implements RtPath { /** * Routing rule. */ private final RtRule rule; /** * Slice under route. */ private final Slice slice; /** * New routing path. * @param rule Rules to apply * @param slice Slice to call */ public RtRulePath(final RtRule rule, final Slice slice) { this.rule = rule; this.slice = slice; } @Override public Optional response( final String line, final Iterable> headers, final Publisher body ) { final Optional res; if (this.rule.apply(line, headers)) { res = Optional.of(this.slice.response(line, headers, body)); } else { res = Optional.empty(); } return res; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy