-
Notifications
You must be signed in to change notification settings - Fork 215
/
HttpRequestActor.java
executable file
·78 lines (69 loc) · 3.09 KB
/
HttpRequestActor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.gateway.service.endpoints.actors;
import java.util.concurrent.CompletableFuture;
import org.eclipse.ditto.base.model.headers.translator.HeaderTranslator;
import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.gateway.service.util.config.endpoints.CommandConfig;
import org.eclipse.ditto.gateway.service.util.config.endpoints.HttpConfig;
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.http.javadsl.model.HttpRequest;
import akka.http.javadsl.model.HttpResponse;
/**
* Every HTTP Request causes one new Actor instance of this one to be created.
* It holds the original sender of an issued {@link Command} and tells this one the completed HttpResponse.
*/
public final class HttpRequestActor extends AbstractHttpRequestActor {
@SuppressWarnings("unused")
private HttpRequestActor(final ActorRef proxyActor,
final HeaderTranslator headerTranslator,
final HttpRequest request,
final CompletableFuture<HttpResponse> httpResponseFuture,
final HttpConfig httpConfig,
final CommandConfig commandConfig) {
super(proxyActor,
headerTranslator,
request,
httpResponseFuture,
httpConfig,
commandConfig);
}
/**
* Creates the Akka configuration object for this {@code HttpRequestActor} for the given {@code proxyActor}, {@code
* request}, and {@code httpResponseFuture} which will be completed with a {@link HttpResponse}.
*
* @param proxyActor the proxy actor which delegates commands.
* @param headerTranslator the {@link org.eclipse.ditto.base.model.headers.translator.HeaderTranslator} used to map ditto headers
* to (external) Http headers.
* @param request the HTTP request
* @param httpResponseFuture the completable future which is completed with a HTTP response.
* @param httpConfig the configuration settings of the Gateway service's HTTP endpoint.
* @param commandConfig the configuration settings for incoming commands (via HTTP requests) in the gateway.
* @return the configuration object.
*/
public static Props props(final ActorRef proxyActor,
final HeaderTranslator headerTranslator,
final HttpRequest request,
final CompletableFuture<HttpResponse> httpResponseFuture,
final HttpConfig httpConfig,
final CommandConfig commandConfig) {
return Props.create(HttpRequestActor.class,
proxyActor,
headerTranslator,
request,
httpResponseFuture,
httpConfig,
commandConfig);
}
}