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 @@ -38,7 +38,9 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import software.amazon.awssdk.services.s3.S3Client;
Expand Down Expand Up @@ -164,6 +166,20 @@ public String mysql() {
return getXrayTraceId();
}

@GetMapping("/status/{code}")
@ResponseBody
public ResponseEntity<String> status(@PathVariable int code, @RequestParam(name = "ip", defaultValue = "localhost") String ip) {
ip = ip.replace("/", "");
try {
HttpGet request = new HttpGet("http://" + ip + ":8081/status/" + code);
httpClient.execute(request).close();
} catch (Exception e) {
// Ignore exception
}
logger.info("Service A requested status code {} from Service B", code);
return ResponseEntity.ok(getXrayTraceId());
}

// get x-ray trace id
private String getXrayTraceId() {
String traceId = Span.current().getSpanContext().getTraceId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

package com.amazon.sampleapp;

import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
Expand All @@ -27,4 +29,9 @@ public class RemoteServiceController {
public String healthcheck() {
return "Remote service healthcheck";
}

@GetMapping("/status/{code}")
public ResponseEntity<String> status(@PathVariable int code) {
return ResponseEntity.status(code).build();
}
}
Loading