|
19 | 19 | import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
|
20 | 20 | import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
|
21 | 21 | import io.micronaut.context.ApplicationContext;
|
| 22 | +import io.micronaut.context.ApplicationContextBuilder; |
22 | 23 | import io.micronaut.context.env.Environment;
|
| 24 | +import io.micronaut.context.env.PropertySource; |
23 | 25 | import io.micronaut.core.annotation.Internal;
|
24 | 26 | import io.micronaut.core.io.socket.SocketUtils;
|
25 | 27 | import io.micronaut.function.aws.proxy.MicronautLambdaHandler;
|
|
28 | 30 | import io.micronaut.http.server.exceptions.ServerStartupException;
|
29 | 31 | import io.micronaut.runtime.ApplicationConfiguration;
|
30 | 32 | import io.micronaut.runtime.server.EmbeddedServer;
|
| 33 | +import jakarta.inject.Singleton; |
31 | 34 | import org.eclipse.jetty.server.Request;
|
32 | 35 | import org.eclipse.jetty.server.Server;
|
33 | 36 | import org.eclipse.jetty.server.handler.AbstractHandler;
|
34 | 37 |
|
35 |
| -import jakarta.inject.Singleton; |
36 | 38 | import javax.servlet.http.HttpServletRequest;
|
37 | 39 | import javax.servlet.http.HttpServletResponse;
|
38 | 40 | import java.io.IOException;
|
@@ -91,7 +93,7 @@ public EmbeddedServer start() {
|
91 | 93 | while (retryCount <= 3) {
|
92 | 94 | try {
|
93 | 95 | this.server = new Server(port);
|
94 |
| - this.server.setHandler(new AwsProxyHandler()); |
| 96 | + this.server.setHandler(new AwsProxyHandler(applicationContext)); |
95 | 97 | this.server.start();
|
96 | 98 | break;
|
97 | 99 | } catch (BindException e) {
|
@@ -181,8 +183,14 @@ private static class AwsProxyHandler extends AbstractHandler {
|
181 | 183 | private final ServletToAwsProxyResponseAdapter responseAdapter;
|
182 | 184 | private final ContextProvider contextProvider;
|
183 | 185 |
|
184 |
| - public AwsProxyHandler() throws ContainerInitializationException { |
185 |
| - lambdaHandler = new MicronautLambdaHandler(); |
| 186 | + public AwsProxyHandler(ApplicationContext proxyTestApplicationContext) throws ContainerInitializationException { |
| 187 | + ApplicationContextBuilder builder = ApplicationContext.builder(); |
| 188 | + for (PropertySource propertySource : proxyTestApplicationContext.getEnvironment() |
| 189 | + .getPropertySources()) { |
| 190 | + builder = builder.propertySources(propertySource); |
| 191 | + } |
| 192 | + lambdaHandler = new MicronautLambdaHandler(builder); |
| 193 | + |
186 | 194 | ApplicationContext ctx = lambdaHandler.getApplicationContext();
|
187 | 195 | this.requestAdapter = ctx.getBean(ServletToAwsProxyRequestAdapter.class);
|
188 | 196 | this.responseAdapter = ctx.getBean(ServletToAwsProxyResponseAdapter.class);
|
|
0 commit comments