diff --git a/READMEold.md b/READMEold.md index 3cf3839..4677bff 100644 --- a/READMEold.md +++ b/READMEold.md @@ -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 diff --git a/src/main/java/io/kerosenelabs/atc/Main.java b/src/main/java/io/kerosenelabs/atc/Main.java index 3c0d3f8..216f44d 100644 --- a/src/main/java/io/kerosenelabs/atc/Main.java +++ b/src/main/java/io/kerosenelabs/atc/Main.java @@ -119,13 +119,13 @@ public static void dispatchThread(SSLSocket socket) { } catch (AtcException e) { log.error("exception occurred while handling client", e); HashMap 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 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); } diff --git a/src/main/java/io/kerosenelabs/atc/client/HttpForwarder.java b/src/main/java/io/kerosenelabs/atc/client/HttpForwarder.java index 3736000..a3d7dd2 100644 --- a/src/main/java/io/kerosenelabs/atc/client/HttpForwarder.java +++ b/src/main/java/io/kerosenelabs/atc/client/HttpForwarder.java @@ -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, diff --git a/src/main/java/io/kerosenelabs/atc/exception/InvalidRequestServiceIdentityException.java b/src/main/java/io/kerosenelabs/atc/exception/InvalidRequestServiceIdentityException.java index 2e3c247..ad4acaf 100644 --- a/src/main/java/io/kerosenelabs/atc/exception/InvalidRequestServiceIdentityException.java +++ b/src/main/java/io/kerosenelabs/atc/exception/InvalidRequestServiceIdentityException.java @@ -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."); } } diff --git a/src/main/java/io/kerosenelabs/atc/server/AtcHttpRequest.java b/src/main/java/io/kerosenelabs/atc/server/AtcHttpRequest.java index 8161008..9da3d31 100644 --- a/src/main/java/io/kerosenelabs/atc/server/AtcHttpRequest.java +++ b/src/main/java/io/kerosenelabs/atc/server/AtcHttpRequest.java @@ -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) @@ -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(); diff --git a/src/main/java/io/kerosenelabs/atc/server/RequestDirector.java b/src/main/java/io/kerosenelabs/atc/server/RequestDirector.java index 59bcb79..3384237 100644 --- a/src/main/java/io/kerosenelabs/atc/server/RequestDirector.java +++ b/src/main/java/io/kerosenelabs/atc/server/RequestDirector.java @@ -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); } /** diff --git a/src/test/java/io/kerosenelabs/atc/client/HttpForwarderTest.java b/src/test/java/io/kerosenelabs/atc/client/HttpForwarderTest.java index e662b57..b036b51 100644 --- a/src/test/java/io/kerosenelabs/atc/client/HttpForwarderTest.java +++ b/src/test/java/io/kerosenelabs/atc/client/HttpForwarderTest.java @@ -44,7 +44,7 @@ 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(); @@ -52,7 +52,7 @@ public class HttpForwarderTest { 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();