Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public void dispatch() {
throw new IllegalStateException("Dispatching already started");
}
dispatched.set(true);
notifyListeners(NotificationType.START_ASYNC, null);
handler.doFilter(req, res, ((AwsServletContext)req.getServletContext()).getServletForPath(req.getRequestURI()));
notifyListeners(NotificationType.START_ASYNC, null);
} catch (ServletException | IOException e) {
notifyListeners(NotificationType.ERROR, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ public void write(int b) throws IOException {
}
}

@Override
public void flush() throws IOException {
flushBuffer();
}

@Override
public void close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ public void initServletAppTest(String reqType) {
handler = new LambdaHandler(type);
}

@MethodSource("data")
@ParameterizedTest
void asyncRequest(String reqType) {
initServletAppTest(reqType);
AwsProxyRequestBuilder req = new AwsProxyRequestBuilder("/async", "POST")
.json()
.body("{\"name\":\"bob\"}");
AwsProxyResponse resp = handler.handleRequest(req, lambdaContext);
assertEquals("{\"name\":\"BOB\"}", resp.getBody());
}

@MethodSource("data")
@ParameterizedTest
void helloRequest_respondsWithSingleMessage(String reqType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
import org.springframework.http.ResponseEntity;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
import org.springframework.web.server.ResponseStatusException;

import jakarta.validation.Valid;
import reactor.core.publisher.Mono;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -18,6 +22,22 @@ public class MessageController {
public static final String UTF8_RESPONSE = "öüäß фрыцшщ";
public static final String EX_MESSAGE = "404 exception message";


@RequestMapping(path="/hi", method=RequestMethod.GET, produces = {"text/plain"})
public Mono<String> hi() {
return Mono.just(HELLO_MESSAGE);
}

@SuppressWarnings({ "unchecked", "rawtypes" })
@RequestMapping(path = "/async", method = RequestMethod.POST)
@ResponseBody
public DeferredResult<Map<String, String>> asyncResult(@RequestBody Map<String, String> value) {
DeferredResult result = new DeferredResult<>();
result.setResult(Collections.singletonMap("name", value.get("name").toUpperCase()));
return result;
}


@RequestMapping(path="/hello", method=RequestMethod.GET, produces = {"text/plain"})
public String hello() {
return HELLO_MESSAGE;
Expand Down