File tree Expand file tree Collapse file tree
src/main/java/com/retailsvc/http Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,8 @@ Response.empty(); // 204 No Content, no body
6262Response . status(404 ); // 404, no body
6363Response . status(200 ); // 200 OK, no body
6464Response . ok(Map . of(" id" , " 42" )); // 200 OK, JSON body via TypeMapper
65+ Response . accepted(); // 202 Accepted, no body
66+ Response . accepted(Map . of(" jobId" , " job-42" )); // 202 Accepted, JSON body
6567Response . of(201 , newResource); // any status, JSON body
6668Response . text(200 , " hello" ); // text/plain; UTF-8
6769Response . bytes(200 , pdf, " application/pdf" ); // pre-serialised bytes
Original file line number Diff line number Diff line change @@ -48,6 +48,16 @@ public static Response ok(Object body) {
4848 return new Response (200 , body , null , Map .of ());
4949 }
5050
51+ /** {@code 202 Accepted} with no body. Use for fire-and-forget async work. */
52+ public static Response accepted () {
53+ return new Response (202 , null , null , Map .of ());
54+ }
55+
56+ /** {@code 202 Accepted} with {@code body} serialised as JSON (typically a job/poll URL). */
57+ public static Response accepted (Object body ) {
58+ return new Response (202 , body , null , Map .of ());
59+ }
60+
5161 /** {@code status} with {@code body} serialised by the content-type's {@link TypeMapper}. */
5262 public static Response of (int status , Object body ) {
5363 return new Response (status , body , null , Map .of ());
You can’t perform that action at this time.
0 commit comments