Skip to content

Commit e8e41cc

Browse files
authored
Merge pull request #83 from awslabs/package-refactor
Refactor preparing for 1.0 release. **This is a breaking change since some classes have moved to new/different packages**
2 parents ba8ea46 + bb07467 commit e8e41cc

File tree

60 files changed

+241
-171
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+241
-171
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ handler.onStartup(c -> {
194194
# Using the Lambda Stream handler
195195
By default, Lambda does not use Jackson annotations when marshalling and unmarhsalling JSON. This can cause issues when receiving requests that include the claims object from a Cognito User Pool authorizer. To support these type of requests, use Lambda's `RequestStreamHandler` interface instead of the POJO-based `RequestHandler`. This allows you to use a custom version of Jackson with support for annotations.
196196

197-
This library uses Jackson annotations in the `com.amazonaws.serverless.proxy.internal.model.CognitoAuthorizerClaims` object. The example below shows how to do this with a `SpringLambdaContainerHandler`, you can use the same methodology with all of the other implementations.
197+
This library uses Jackson annotations in the `com.amazonaws.serverless.proxy.model.CognitoAuthorizerClaims` object. The example below shows how to do this with a `SpringLambdaContainerHandler`, you can use the same methodology with all of the other implementations.
198198

199199
```java
200200
public class StreamLambdaHandler implements RequestStreamHandler {

aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/exceptions/ContainerInitializationException.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
*/
1313
package com.amazonaws.serverless.exceptions;
1414

15+
16+
import com.amazonaws.serverless.proxy.RequestReader;
17+
18+
1519
/**
1620
* This exception is thrown when the ContainerHandler fails to parse a request object or input stream into the
1721
* object required by the Container. The exception is thrown by implementing sub-classes of <code>RequestReader</code>
1822
*
19-
* @see com.amazonaws.serverless.proxy.internal.RequestReader
23+
* @see RequestReader
2024
*/
2125
public class ContainerInitializationException extends Exception {
2226
public ContainerInitializationException(String message, Exception e) {

aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/exceptions/InvalidRequestEventException.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
*/
1313
package com.amazonaws.serverless.exceptions;
1414

15+
16+
import com.amazonaws.serverless.proxy.RequestReader;
17+
18+
1519
/**
1620
* This exception is thrown when the ContainerHandler fails to parse a request object or input stream into the
1721
* object required by the Container. The exception is thrown by implementing sub-classes of <code>RequestReader</code>
1822
*
19-
* @see com.amazonaws.serverless.proxy.internal.RequestReader
23+
* @see RequestReader
2024
*/
2125
public class InvalidRequestEventException extends Exception {
2226
public InvalidRequestEventException(String message, Exception e) {

aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/exceptions/InvalidResponseObjectException.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
*/
1313
package com.amazonaws.serverless.exceptions;
1414

15+
16+
import com.amazonaws.serverless.proxy.ResponseWriter;
17+
18+
1519
/**
1620
* This exception is thrown when the ContainerHandler cannot transform the Container response into a valid return value
1721
* for the Lambda function. This exception is thrown by implementing sub-classes of <code>ResponseWriter</code>
1822
*
19-
* @see com.amazonaws.serverless.proxy.internal.ResponseWriter
23+
* @see ResponseWriter
2024
*/
2125
public class InvalidResponseObjectException extends Exception {
2226
public InvalidResponseObjectException(String message, Exception e) {
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1111
* and limitations under the License.
1212
*/
13-
package com.amazonaws.serverless.proxy.internal;
13+
package com.amazonaws.serverless.proxy;
1414

1515
import com.amazonaws.serverless.exceptions.InvalidRequestEventException;
16-
import com.amazonaws.serverless.proxy.internal.model.AwsProxyResponse;
17-
import com.amazonaws.serverless.proxy.internal.model.ErrorModel;
16+
import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
17+
import com.amazonaws.serverless.proxy.model.ErrorModel;
18+
1819
import com.fasterxml.jackson.core.JsonProcessingException;
1920
import com.fasterxml.jackson.databind.ObjectMapper;
2021
import org.slf4j.Logger;
@@ -34,7 +35,7 @@
3435
* Returns application/json messages with a status code of 500 when the RequestReader failed to read the incoming event.
3536
* For all other exceptions returns a 502. Responses are populated with a JSON object containing a message property.
3637
*
37-
* @see com.amazonaws.serverless.proxy.internal.ExceptionHandler
38+
* @see ExceptionHandler
3839
*/
3940
public class AwsProxyExceptionHandler
4041
implements ExceptionHandler<AwsProxyResponse> {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1111
* and limitations under the License.
1212
*/
13-
package com.amazonaws.serverless.proxy.internal;
13+
package com.amazonaws.serverless.proxy;
1414

1515
import com.amazonaws.serverless.proxy.internal.jaxrs.AwsProxySecurityContext;
16-
import com.amazonaws.serverless.proxy.internal.model.AwsProxyRequest;
16+
import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
1717
import com.amazonaws.services.lambda.runtime.Context;
1818

1919
import javax.ws.rs.core.SecurityContext;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1111
* and limitations under the License.
1212
*/
13-
package com.amazonaws.serverless.proxy.internal;
13+
package com.amazonaws.serverless.proxy;
1414

1515
import java.io.IOException;
1616
import java.io.OutputStream;
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,15 @@
1010
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1111
* and limitations under the License.
1212
*/
13-
package com.amazonaws.serverless.proxy.internal;
13+
package com.amazonaws.serverless.proxy;
1414

1515

1616
import com.amazonaws.serverless.exceptions.InvalidRequestEventException;
17-
import com.amazonaws.serverless.proxy.internal.model.ContainerConfig;
17+
import com.amazonaws.serverless.proxy.model.ContainerConfig;
1818
import com.amazonaws.services.lambda.runtime.Context;
1919

20-
import com.fasterxml.jackson.databind.ObjectMapper;
21-
2220
import javax.ws.rs.core.SecurityContext;
2321

24-
import java.io.IOException;
25-
import java.io.InputStream;
26-
2722

2823
/**
2924
* Implementations of the RequestReader object are used by container objects to transform the incoming Lambda event into
@@ -63,13 +58,13 @@ public abstract class RequestReader<RequestType, ContainerRequestType> {
6358
/**
6459
* Reads the incoming event object and produces a populated request for the underlying container
6560
* @param request The incoming request object
66-
* @param securityContext A jax-rs SecurityContext object (@see com.amazonaws.serverless.proxy.internal.SecurityContextWriter)
61+
* @param securityContext A jax-rs SecurityContext object (@see com.amazonaws.serverless.proxy.SecurityContextWriter)
6762
* @param lambdaContext The AWS Lambda context for the request
6863
* @param config The container configuration object. This is passed in by the LambdaContainerHandler.
6964
* @return A valid request object for the underlying container
7065
* @throws InvalidRequestEventException This exception is thrown if anything goes wrong during the creation of the request object
7166
*/
72-
protected abstract ContainerRequestType readRequest(RequestType request, SecurityContext securityContext, Context lambdaContext, ContainerConfig config)
67+
public abstract ContainerRequestType readRequest(RequestType request, SecurityContext securityContext, Context lambdaContext, ContainerConfig config)
7368
throws InvalidRequestEventException;
7469

7570

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1111
* and limitations under the License.
1212
*/
13-
package com.amazonaws.serverless.proxy.internal;
13+
package com.amazonaws.serverless.proxy;
1414

1515

1616
import com.amazonaws.serverless.exceptions.InvalidResponseObjectException;
@@ -44,7 +44,7 @@ public abstract class ResponseWriter<ContainerResponseType, ResponseType> {
4444
* @return A valid return value for the Lambda function
4545
* @throws InvalidResponseObjectException When the implementation cannot read the container response object
4646
*/
47-
protected abstract ResponseType writeResponse(ContainerResponseType containerResponse, Context lambdaContext)
47+
public abstract ResponseType writeResponse(ContainerResponseType containerResponse, Context lambdaContext)
4848
throws InvalidResponseObjectException;
4949

5050
/**
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1111
* and limitations under the License.
1212
*/
13-
package com.amazonaws.serverless.proxy.internal;
13+
package com.amazonaws.serverless.proxy;
1414

15-
import com.amazonaws.serverless.proxy.internal.model.AwsProxyRequest;
15+
import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
1616
import com.amazonaws.services.lambda.runtime.Context;
1717

1818
import javax.ws.rs.core.SecurityContext;

0 commit comments

Comments
 (0)