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

ch.digitalfondue.nihttpsuite.Request Maven / Gradle / Ivy

The newest version!
/**
 * Copyright © 2020 digitalfondue ([email protected])
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package ch.digitalfondue.nihttpsuite;

import java.util.List;
import java.util.Optional;

/**
 * Represent a HTTP request.
 */
public interface Request {

    /**
     * Return requested path. For example: "/test/path"
     *
     * @return path.
     */
    String getPath();

    /**
     * Get list of header names.
     *
     * @return header names
     */
    List getHeaderNames();

    /**
     * Get list of headers with the given name.
     *
     * @param name of the http header
     * @return header values
     */
    List getHeaders(String name);

    /**
     * Return first header value for a given name.
     *
     * @param name of the http header
     * @return first header value
     */
    Optional getHeader(String name);

    /**
     * Get first value for given query parameter name.
     *
     * @param name of the query parameter
     * @return query parameter value
     */
    Optional getQueryParameter(String name);

    /**
     * Get all values for given query parameter name.
     *
     * @param name of the query parameter
     * @return query parameter values
     */
    List getQueryParameters(String name);

    /**
     * Get context. See {@link Context}
     *
     * @return context.
     */
    Context context();

    /**
     * Get value of path variable defined in route.
     * For example: "/my/{var}", path is "/my/test": getPathVariable("var") return "test".
     *
     * @param name of the path variable
     * @return path variable value.
     */
    String getPathVariable(String name);
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy