Skip to content
Open
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 @@ -2,13 +2,16 @@

import java.util.Optional;

import javax.servlet.http.HttpServletResponse;

import com.sap.cloud.service.flags.demo.service.FeatureFlagsService;
import com.sap.cloud.service.flags.demo.service.FlagStatus;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import com.sap.cloud.service.flags.demo.service.FeatureFlagsService;

/**
* Represents a controller that uses the feature toggling practice.
*/
Expand Down Expand Up @@ -52,17 +55,23 @@ public String getIndex(final ModelMap modelMap) {
* - ID of the feature flag
* @param modelMap
* - the {@link ModelMap}
* @param rsp
* - the {@link HttpServletResponse}
*
* @return the evaluation view
*/

@GetMapping("/evaluate/{id}")
public String evaluate(@PathVariable final String id, final ModelMap modelMap) {
public String evaluate(@PathVariable final String id, final ModelMap modelMap, final HttpServletResponse rsp) {
String status;
if (!hasBoundServiceInstance()) {
status = "missing-service-instance";
rsp.setStatus(500);
} else {
status = featureFlagsServiceOptional.get().getFlagStatus(id).toString();
if (status.equals(FlagStatus.MISSING.toString())) {
rsp.setStatus(404);
}
}

modelMap.addAttribute("status", status);
Expand Down