Skip to content

Commit

Permalink
Configurable server name (#3)
Browse files Browse the repository at this point in the history
* add configurable server name

* cache stores raw responses, rewritten on read
  • Loading branch information
briantist authored Jun 20, 2022
1 parent 5fc8dbd commit 3d9994f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions galactory/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
)
parser.add_argument('--listen-addr', default='0.0.0.0', type=str, help='The IP address to listen on.')
parser.add_argument('--listen-port', default=5555, type=int, help='The TCP port to listen on.')
parser.add_argument('--server-name', type=str, help='The host name and port of the server, as seen from clients. Used for generating links.')
parser.add_argument('--artifactory-path', type=str, required=True, help='The URL of the path in Artifactory where collections are stored.')
parser.add_argument('--artifactory-api-key', default=os.environ.get('GALACTORY_ARTIFACTORY_API_KEY'), help='If set, is the API key used to access Artifactory.')
parser.add_argument('--use-galaxy-key', action='store_true', help='If set, uses the Galaxy token as the Artifactory API key.')
Expand Down Expand Up @@ -47,6 +48,7 @@
ARTIFACTORY_API_KEY=args.artifactory_api_key,
USE_GALAXY_KEY=args.use_galaxy_key,
PREFER_CONFIGURED_KEY=args.prefer_configured_key,
SERVER_NAME=args.server_name,
)

print(app.url_map)
Expand Down
5 changes: 2 additions & 3 deletions galactory/upstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,15 @@ def proxy(self, request):
# else:
# abort(Response(resp.text, resp.status_code))


else:
current_app.logger.info(f"Cache miss: {request.url}")
data = self._rewrite_upstream_response(resp.json(), request.url_root)
data = resp.json()
cache.data = data
self._set_cache(request, cache)
else:
current_app.logger.info(f"Cache hit: {request.url}")

return cache.data
return self._rewrite_upstream_response(cache.data, request.url_root)

def _rewrite_upstream_response(self, response_data, url_root) -> dict:
ret = {}
Expand Down

0 comments on commit 3d9994f

Please sign in to comment.