Skip to content
Open
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
@@ -1,12 +1,14 @@
package io.americanexpress.synapse.api.rest.imperative.controller;

import io.americanexpress.synapse.api.rest.imperative.controller.helpers.CreateResponseEntityCreator;
import io.americanexpress.synapse.api.rest.imperative.controller.helpers.MonoResponseEntityCreator;
import io.americanexpress.synapse.service.imperative.model.BaseServiceRequest;
import io.americanexpress.synapse.service.imperative.model.BaseServiceResponse;
import io.americanexpress.synapse.service.imperative.service.BaseService;
import jakarta.validation.Valid;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;

/**
Expand All @@ -30,10 +32,10 @@ public class BaseUpdateImperativeRestController<
* @return response to the consumer
*/
@PutMapping
public ResponseEntity<O> update(@RequestHeader HttpHeaders headers, I serviceRequest) {
public ResponseEntity<O> update(@RequestHeader HttpHeaders headers, @RequestBody @Valid I serviceRequest) {
logger.entry(serviceRequest);
O serviceResponse = service.execute(serviceRequest);
ResponseEntity<O> responseEntity = CreateResponseEntityCreator.create(serviceResponse);
ResponseEntity<O> responseEntity = MonoResponseEntityCreator.create(serviceResponse);
logger.exit();
return responseEntity;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class HealthCheckController {
/**
* The health global Geographically Distributed High Availability (gdha) check endpoint.
*/
public static final String HEALTH_CHECK__GDHA_ENDPOINT = "/health-gdha";
public static final String HEALTH_CHECK_GDHA_ENDPOINT = "/health-gdha";

/**
* Health message used for the health check URIs.
Expand All @@ -52,7 +52,7 @@ public String healthCheck() {
*
* @return a constant message to notify that the service is receiving a request
*/
@GetMapping(HEALTH_CHECK__GDHA_ENDPOINT)
@GetMapping(HEALTH_CHECK_GDHA_ENDPOINT)
public String healthGdhaCheck() {
return HEALTH_MESSAGE;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2020 American Express Travel Related Services Company, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package io.americanexpress.synapse.service.imperative.model;

/**
* {@code NullServiceResponse} is used whenever a null response is required from a service. The service can just return
* NullServiceResponse.INSTANCE rather than just returning null directly as this class also extends {@code BaseServiceResponse}
* adhering to the prototype contracts.
*/
public class NullServiceResponse implements BaseServiceResponse {
Copy link
Collaborator

@guttff guttff Jan 30, 2025

Choose a reason for hiding this comment

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

I would rename this file to either EmptyServiceResponse or NoServiceResponse or better a name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we thought about it but if this class's INSTANCE method is returning back Null would it make sense to have EmptyServiceResponse.INSTANCE = null instead of NullServiceResponse.INSTANCE = null? if you think so then I'm good to change it


/**
* Returns a null instance as a singleton pattern for when a null response is required from the service.
*/
public static final NullServiceResponse INSTANCE = null;

/**
* Private constructor to prevent multiple instances being made.
*/
private NullServiceResponse() {

}
}