2 * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.restconf.server.api;
10 import java.util.function.Function;
11 import org.eclipse.jdt.annotation.NonNullByDefault;
12 import org.opendaylight.restconf.api.QueryParameters;
13 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
16 * A request to {@link RestconfServer}. It contains state and binding established by whoever is performing binding to
17 * HTTP transport layer. This includes:
19 * <li>HTTP request {@link #queryParameters() query parameters},</li>
21 * It notably does <b>not</b> hold the HTTP request path, nor the request body. Those are passed as separate arguments
22 * to server methods as implementations of those methods are expected to act on them.
24 * @param <T> type of reported result
27 public sealed interface ServerRequest<T> permits AbstractServerRequest, TransformedServerRequest {
29 QueryParameters queryParameters();
31 void completeWith(T result);
33 // FIXME: NETCONF-1188: remove in favor of ServerException
34 void completeWith(RestconfDocumentedException failure);
36 default void completeWith(final ServerException failure) {
37 completeWith(failure.toLegacy());
40 default <O> ServerRequest<O> transform(final Function<O, T> function) {
41 return new TransformedServerRequest<>(this, function);