mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 03:08:14 +00:00
Add api versionning
This commit is contained in:
parent
119bebee25
commit
08158884a4
@ -84,7 +84,8 @@ class Route(object):
|
||||
# This block is executed only the first time
|
||||
output_schema = kw.get("output", {})
|
||||
input_schema = kw.get("input", {})
|
||||
cls._path = path
|
||||
api_version = kw.get("version", 1)
|
||||
cls._path = "/v{version}{path}".format(path=path, version=api_version)
|
||||
cls._documentation.setdefault(cls._path, {"methods": []})
|
||||
|
||||
def register(func):
|
||||
|
@ -45,7 +45,7 @@ class Query:
|
||||
return self._fetch("DELETE", path, **kwargs)
|
||||
|
||||
def _get_url(self, path):
|
||||
return "http://{}:{}{}".format(self._host, self._port, path)
|
||||
return "http://{}:{}/v1{}".format(self._host, self._port, path)
|
||||
|
||||
def _fetch(self, method, path, body=None, **kwargs):
|
||||
"""Fetch an url, parse the JSON and return response
|
||||
@ -74,7 +74,7 @@ class Query:
|
||||
asyncio.async(go(future, response))
|
||||
self._loop.run_until_complete(future)
|
||||
response.body = future.result()
|
||||
response.route = response.headers.get('X-Route', None)
|
||||
response.route = response.headers.get('X-Route', None).replace("/v1", "")
|
||||
|
||||
if response.body is not None:
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user