mirror of https://github.com/CIRCL/AIL-framework
chg: [api] 405 response: add url to api endpoint documentation
parent
4ce548ab84
commit
0a071a5165
|
@ -18,7 +18,6 @@ When submitting data in a POST, PUT or DELETE operation you need to specify in w
|
|||
~~~~
|
||||
Content-Type: application/json
|
||||
~~~~
|
||||
Take me to [delete_item_tag](#delete_item_tag)
|
||||
|
||||
Example:
|
||||
|
||||
|
|
|
@ -294,7 +294,12 @@ def searchbox():
|
|||
@app.errorhandler(405)
|
||||
def _handle_client_error(e):
|
||||
if request.path.startswith('/api/'):
|
||||
return Response(json.dumps({"status": "error", "reason": "Method Not Allowed: The method is not allowed for the requested URL"}, indent=2, sort_keys=True), mimetype='application/json'), 405
|
||||
res_dict = {"status": "error", "reason": "Method Not Allowed: The method is not allowed for the requested URL"}
|
||||
anchor_id = request.path[8:]
|
||||
anchor_id = anchor_id.replace('/', '_')
|
||||
api_doc_url = 'https://github.com/CIRCL/AIL-framework/tree/master/doc#{}'.format(anchor_id)
|
||||
res_dict['documentation'] = api_doc_url
|
||||
return Response(json.dumps(res_dict, indent=2, sort_keys=True), mimetype='application/json'), 405
|
||||
else:
|
||||
return e
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ r_serv_db = Flask_config.r_serv_db
|
|||
r_serv_onion = Flask_config.r_serv_onion
|
||||
r_serv_metadata = Flask_config.r_serv_metadata
|
||||
|
||||
|
||||
restApi = Blueprint('restApi', __name__, template_folder='templates')
|
||||
|
||||
# ============ AUTH FUNCTIONS ============
|
||||
|
@ -128,8 +129,6 @@ def authErrors(user_role):
|
|||
|
||||
# ============ API CORE =============
|
||||
|
||||
|
||||
|
||||
# ============ FUNCTIONS ============
|
||||
|
||||
def is_valid_uuid_v4(header_uuid):
|
||||
|
@ -167,26 +166,22 @@ def one():
|
|||
# }
|
||||
#
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
@restApi.route("api/v1/get/item", methods=['GET', 'POST'])
|
||||
@restApi.route("api/v1/get/item", methods=['POST'])
|
||||
@token_required('analyst')
|
||||
def get_item_id():
|
||||
if request.method == 'POST':
|
||||
data = request.get_json()
|
||||
res = Item.get_item(data)
|
||||
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
||||
else:
|
||||
return 'description API endpoint'
|
||||
data = request.get_json()
|
||||
res = Item.get_item(data)
|
||||
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
||||
|
||||
@restApi.route("api/v1/get/item/default", methods=['POST'])
|
||||
@token_required('analyst')
|
||||
def get_item_id_basic():
|
||||
|
||||
if request.method == 'POST':
|
||||
data = request.get_json()
|
||||
item_id = data.get('id', None)
|
||||
req_data = {'id': item_id, 'date': True, 'content': True, 'tags': True}
|
||||
res = Item.get_item(req_data)
|
||||
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
||||
data = request.get_json()
|
||||
item_id = data.get('id', None)
|
||||
req_data = {'id': item_id, 'date': True, 'content': True, 'tags': True}
|
||||
res = Item.get_item(req_data)
|
||||
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# GET
|
||||
|
|
Loading…
Reference in New Issue