feat(Global): Add health check api
This commit is contained in:
parent
2b2de0123a
commit
0bd9434d12
2 changed files with 10 additions and 4 deletions
|
@ -1,3 +1,9 @@
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
|
|
||||||
api_v1 = Blueprint('api_v1', __name__, url_prefix='/api/v1')
|
api_v1 = Blueprint("api_v1", __name__, url_prefix="/api/v1")
|
||||||
|
|
||||||
|
|
||||||
|
@api_v1.route("/")
|
||||||
|
@api_v1.route("/health")
|
||||||
|
def api_index():
|
||||||
|
return "Open App Stack API v1.0"
|
||||||
|
|
|
@ -12,7 +12,7 @@ class BadRequest(Exception):
|
||||||
|
|
||||||
def bad_request_error(e):
|
def bad_request_error(e):
|
||||||
message = e.args[0] if e.args else "Bad request to the server."
|
message = e.args[0] if e.args else "Bad request to the server."
|
||||||
return jsonify({"errorMessage": message})
|
return jsonify({"errorMessage": message}), 400
|
||||||
|
|
||||||
|
|
||||||
def validation_error(e):
|
def validation_error(e):
|
||||||
|
@ -24,11 +24,11 @@ def validation_error(e):
|
||||||
|
|
||||||
|
|
||||||
def kratos_error(e):
|
def kratos_error(e):
|
||||||
message = e.args[0] if e.args else "Failed to contant Kratos."
|
message = e.args[0] if e.args else "Failed to contact Kratos."
|
||||||
status_code = e.args[1] if e.args else 500
|
status_code = e.args[1] if e.args else 500
|
||||||
return jsonify({"errorMessage": message}), status_code
|
return jsonify({"errorMessage": message}), status_code
|
||||||
|
|
||||||
|
|
||||||
def global_error(e):
|
def global_error(e):
|
||||||
message = e.args[0] if e.args else "Something went wrong."
|
message = str(e)
|
||||||
return jsonify({"errorMessage": message})
|
return jsonify({"errorMessage": message})
|
||||||
|
|
Loading…
Reference in a new issue