mirror of
https://github.com/ilri/dspace-statistics-api.git
synced 2024-11-22 06:15:02 +01:00
Add /status route
Currently this only prints the API version.
This commit is contained in:
parent
a9d2a6d9be
commit
4b1398c67f
@ -5,6 +5,7 @@ from falcon_swagger_ui import register_swaggerui_app
|
|||||||
from .database import DatabaseManager
|
from .database import DatabaseManager
|
||||||
from .stats import get_downloads, get_views
|
from .stats import get_downloads, get_views
|
||||||
from .util import set_statistics_scope, validate_post_parameters
|
from .util import set_statistics_scope, validate_post_parameters
|
||||||
|
from .config import VERSION
|
||||||
|
|
||||||
|
|
||||||
class RootResource:
|
class RootResource:
|
||||||
@ -15,6 +16,14 @@ class RootResource:
|
|||||||
resp.body = f.read()
|
resp.body = f.read()
|
||||||
|
|
||||||
|
|
||||||
|
class StatusResource:
|
||||||
|
def on_get(self, req, resp):
|
||||||
|
message = {"version": VERSION}
|
||||||
|
|
||||||
|
resp.status = falcon.HTTP_200
|
||||||
|
resp.media = message
|
||||||
|
|
||||||
|
|
||||||
class OpenAPIJSONResource:
|
class OpenAPIJSONResource:
|
||||||
def on_get(self, req, resp):
|
def on_get(self, req, resp):
|
||||||
resp.status = falcon.HTTP_200
|
resp.status = falcon.HTTP_200
|
||||||
@ -174,6 +183,7 @@ class SingleStatisticsResource:
|
|||||||
|
|
||||||
api = application = falcon.API()
|
api = application = falcon.API()
|
||||||
api.add_route("/", RootResource())
|
api.add_route("/", RootResource())
|
||||||
|
api.add_route("/status", StatusResource())
|
||||||
|
|
||||||
# Item routes
|
# Item routes
|
||||||
api.add_route("/items", AllStatisticsResource())
|
api.add_route("/items", AllStatisticsResource())
|
||||||
|
@ -9,4 +9,6 @@ DATABASE_PASS = os.environ.get("DATABASE_PASS", "dspacestatistics")
|
|||||||
DATABASE_HOST = os.environ.get("DATABASE_HOST", "localhost")
|
DATABASE_HOST = os.environ.get("DATABASE_HOST", "localhost")
|
||||||
DATABASE_PORT = os.environ.get("DATABASE_PORT", "5432")
|
DATABASE_PORT = os.environ.get("DATABASE_PORT", "5432")
|
||||||
|
|
||||||
|
VERSION = "1.4.0-dev"
|
||||||
|
|
||||||
# vim: set sw=4 ts=4 expandtab:
|
# vim: set sw=4 ts=4 expandtab:
|
||||||
|
@ -34,3 +34,12 @@ def test_get_swagger_ui(client):
|
|||||||
|
|
||||||
assert isinstance(response.content, bytes)
|
assert isinstance(response.content, bytes)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_status(client):
|
||||||
|
"""Test requesting the status page."""
|
||||||
|
|
||||||
|
response = client.simulate_get("/status")
|
||||||
|
|
||||||
|
assert isinstance(response.content, bytes)
|
||||||
|
assert response.status_code == 200
|
||||||
|
Loading…
Reference in New Issue
Block a user