Skip to content

Commit

Permalink
[V6] Make http service use v0 routes by default (#41)
Browse files Browse the repository at this point in the history
Made API version to be '/v0' by default. Other options are '/v1' or
'/latest', also '' is option which default to v0 for backwards
compatibility reasons I believe. Tested on local network and client
functions as expected.

V8 branch will pass 'v1' for the version, or we can make it
programatically in the code decide whether to pass v0 or v1 somehow
depending on how we want to roll out v8
  • Loading branch information
brkagithub authored Dec 5, 2024
2 parents f1706bc + de5652e commit 4c00a7c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions dkg/providers/node_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,18 @@


class NodeHTTPProvider:
def __init__(self, endpoint_uri: URI | str, auth_token: str | None = None):
def __init__(
self,
endpoint_uri: URI | str,
auth_token: str | None = None,
api_version: str = "v0",
):
self.endpoint_uri = URI(endpoint_uri)
self.auth_token = auth_token
self.api_version = api_version

def get_full_url(self, path: str) -> str:
return f"{self.endpoint_uri}/{self.api_version}/{path}"

def make_request(
self,
Expand All @@ -36,7 +45,7 @@ def make_request(
params: dict[str, Any] = {},
data: dict[str, Any] = {},
) -> NodeResponseDict:
url = f"{self.endpoint_uri}/{path}"
url = self.get_full_url(path)
headers = (
{"Authorization": f"Bearer {self.auth_token}"} if self.auth_token else {}
)
Expand Down

0 comments on commit 4c00a7c

Please sign in to comment.