Skip to content
Draft
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<groupId>io.americanexpress.synapse</groupId>
<artifactId>synapse</artifactId>
<packaging>pom</packaging>
<version>0.4.11-SNAPSHOT</version>
<version>0.4.13-SNAPSHOT</version>

<description>
Synapse is a set of lightweight foundational framework modules for rapid development built-in with enterprise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,32 @@ public Mono<ResponseEntity<O>> read(@RequestHeader HttpHeaders headers, @PathVar
logger.exit(responseEntity);
return responseEntity;
}


/**
* Get a single resource from the back end service.
*
* @param headers the headers
* @return response
*/
@Operation(summary = "Reactive get mono", description = "Get resources reactively")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok"),
@ApiResponse(responseCode = "204", description = "No Content"),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "403", description = "Forbidden"),
})
@GetMapping("/")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wont this clash with BaseGetFluxReactiveController

public Mono<ResponseEntity<O>> read(@RequestHeader HttpHeaders headers) {
logger.entry(headers);

var serviceResponse = service.read(headers);
var responseEntity = serviceResponse
.map(ResponseEntity::ok)
.defaultIfEmpty(ResponseEntity.noContent().build());

logger.exit(responseEntity);
return responseEntity;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,28 @@
*/
public abstract class BaseGetMonoReactiveService<O extends BaseServiceResponse> extends BaseService {


/**
* Retrieves one resource.
*
* @param headers headers
* @return a mono read response
*/
public Mono<O> read(HttpHeaders headers) {
logger.entry(headers);
final var response = executeRead(headers);
logger.exit();
return response;
}

/**
* Prototype for reading a resource.
*
* @param headers headers
* @return a mono read response
*/
protected abstract Mono<O> executeRead(HttpHeaders headers);

/**
* Retrieves one resource.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@
*/
public class BaseGetMonoController<O extends BaseServiceResponse, S extends BaseGetMonoService<O>> extends BaseController<S> {


/**
* Read response entity.
*
* @param headers containing the HTTP headers from the consumer
* @return the response entity
*/
@Operation(summary = "Read operation.", description = "Read resources.")
@GetMapping("/")
public ResponseEntity<O> read(@RequestHeader HttpHeaders headers) {
logger.entry(headers);

final O response = service.read(headers);
ResponseEntity<O> responseEntity = MonoResponseEntityCreator.create(response);

logger.exit(responseEntity);
return responseEntity;
}
/**
* Read response entity.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,31 @@
*/
public abstract class BaseGetMonoService<O extends BaseServiceResponse> extends BaseService {


/**
* Gets a single resource.
*
* @param headers received from the controller
*/
public O read(HttpHeaders headers) {

logger.entry(headers);

O response = executeRead(headers);

logger.exit(response);

return response;
}

/**
* Prototype for reading a resource.
* @param headers
* @return
*/
protected abstract O executeRead(HttpHeaders headers);


/**
* Gets a single resource.
*
Expand Down