Skip to content

Commit

Permalink
#28 changing rd branding
Browse files Browse the repository at this point in the history
  • Loading branch information
hlafaille committed May 15, 2024
1 parent 0828a52 commit 9e8a94b
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions READMEold.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ ATC will automatically detect `configuration.yml` file changes and apply them, n

### Fork requests

Call an endpoint on a service with the `X-RD-ForkMode: 1` header and receive a "Forked Request ID" in response. Poll the endpoint again with `X-RD-ForkId: yourForkIdHere`, receiving `HTTP 503 Service Temporarily Unavailable` if the response is still not available, or receiving the proper response from your service.
Call an endpoint on a service with the `X-ATC-ForkMode: 1` header and receive a "Forked Request ID" in response. Poll the endpoint again with `X-ATC-ForkId: yourForkIdHere`, receiving `HTTP 503 Service Temporarily Unavailable` if the response is still not available, or receiving the proper response from your service.

### Tracing

Automated tracing with the `X-RD-Trace` header.
Automated tracing with the `X-ATC-Trace` header.

# How it works

ATC in a nutshell is an API gateway that handles directing requests to your internal services. When writing an
application consuming internal APIs, your application will actually be talking to a ATC instance. ATC checks your application's `X-RD-Access` header, compares it with issued access tokens, then compares it with allowed scopes and routes your request accordingly (or responds with an error).
application consuming internal APIs, your application will actually be talking to a ATC instance. ATC checks your application's `X-ATC-Access` header, compares it with issued access tokens, then compares it with allowed scopes and routes your request accordingly (or responds with an error).

# How to use it

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/kerosenelabs/atc/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ public static void dispatchThread(SSLSocket socket) {
} catch (AtcException e) {
log.error("exception occurred while handling client", e);
HashMap<String, String> headers = new HashMap<>();
headers.put("X-RD-Error", e.getErrorCode().toString());
headers.put("X-ATC-Error", e.getErrorCode().toString());
httpResponse = new AtcHttpResponse(e.getHttpStatus(), headers, null);
} catch (Exception e) {
// if any error during request/response lifecycle happened
log.error("exception occurred while handling client", e);
HashMap<String, String> headers = new HashMap<>();
headers.put("X-RD-Error", ErrorCode.ERROR_OCCURRED_DURING_REQUEST_HANDLING.toString());
headers.put("X-ATC-Error", ErrorCode.ERROR_OCCURRED_DURING_REQUEST_HANDLING.toString());
httpResponse = new AtcHttpResponse(HttpStatus.INTERNAL_SERVER_ERROR, headers, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private static AtcHttpResponse convertStdHttpResponseToAtcHttpResponse(HttpRespo
}

// add our header to let the client know we're involved
responseHeaders.put("X-RD-InLine", "1");
responseHeaders.put("X-ATC-InLine", "1");

// convert a stdlib HttpResponse to our custom HttpResponse
return new AtcHttpResponse(HttpStatus.getFromCode(httpResponse.statusCode()), responseHeaders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
public class InvalidRequestServiceIdentityException extends AtcException {
public InvalidRequestServiceIdentityException() {
super(HttpStatus.BAD_REQUEST, ErrorCode.ERROR_OCCURRED_DURING_REQUEST_HANDLING,
"Request is missing 'X-RD-ServiceIdentity' header, which is required for ALL requests.");
"Request is missing 'X-ATC-ServiceIdentity' header, which is required for ALL requests.");
}
}
6 changes: 3 additions & 3 deletions src/main/java/io/kerosenelabs/atc/server/AtcHttpRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private static String parseContent(int contentLength, BufferedReader bufferedRea
* @throws MalformedHttpMessage
* @throws IOException
* @throws RequestMissingServiceIdentityException If the
* {@code X-RD-ServiceIdentity}
* {@code X-ATC-ServiceIdentity}
* header is missing
*/
public AtcHttpRequest(BufferedReader bufferedReader)
Expand All @@ -163,9 +163,9 @@ public AtcHttpRequest(BufferedReader bufferedReader)
} catch (HeaderNotFoundException e) {
}

// ensure that the X-RD-ServiceIdentity header is set
// ensure that the X-ATC-ServiceIdentity header is set
try {
HttpHeader serviceIdentityHeader = headers.getByName("x-rd-serviceidentity");
HttpHeader serviceIdentityHeader = headers.getByName("x-atc-serviceidentity");
consumingServiceIdentity = serviceIdentityHeader.getValue();
} catch (HeaderNotFoundException e) {
throw new InvalidRequestServiceIdentityException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public RequestDirector(AtcHttpRequest httpRequest, String traceId) {
*/
private void generateBaseResponseHeaders() {
this.headers = new HashMap<>();
headers.put("X-RD-Trace", traceId);
headers.put("X-ATC-Trace", traceId);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ public class HttpForwarderTest {
.append("Host: api.example.com\r\n")
.append("Accept: application/json\r\n")
.append("Content-Length: 23\r\n")
.append("X-RD-ServiceIdentity: test")
.append("X-ATC-ServiceIdentity: test")
.append("Content-Type: application/json\r\n\r\n")
.append("{\"message\": \"request\"}\r\n")
.toString();

private final String testRawHttpRequestNoContent = new StringBuilder()
.append("GET /endpoint HTTP/1.1\r\n")
.append("Host: api.example.com\r\n")
.append("X-RD-ServiceIdentity: test")
.append("X-ATC-ServiceIdentity: test")
.append("Accept: application/json\r\n\r\n")
.toString();

Expand Down

0 comments on commit 9e8a94b

Please sign in to comment.