mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-30 01:37:17 +00:00
chg: [api] 405 response: add url to api endpoint documentation
This commit is contained in:
parent
4ce548ab84
commit
0a071a5165
3 changed files with 16 additions and 17 deletions
|
@ -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,21 +166,17 @@ 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'
|
||||
|
||||
@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}
|
||||
|
|
Loading…
Reference in a new issue