Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
add sunset header to root response, reorder decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
argl committed Oct 7, 2024
1 parent 5f03a08 commit 51ac0db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
16 changes: 8 additions & 8 deletions httpobs/website/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@


@api.route('/api/v1/analyze', methods=['GET', 'OPTIONS', 'POST'])
@check_for_deprecation_override_header
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers(cors=True)
@sanitized_api_response
def api_post_scan_hostname():
Expand Down Expand Up @@ -121,8 +121,8 @@ def api_post_scan_hostname():

# TODO: Deprecate this and replace with __stats__ once website is updated
@api.route('/api/v1/getGradeDistribution', methods=['GET', 'OPTIONS'])
@check_for_deprecation_override_header
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers(cors=True)
def api_get_grade_totals():
totals = database.select_star_from('grade_distribution')
Expand All @@ -134,8 +134,8 @@ def api_get_grade_totals():


@api.route('/api/v1/getHostHistory', methods=['GET', 'OPTIONS'])
@check_for_deprecation_override_header
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers(cors=True)
def api_get_host_history():
# Get the hostname
Expand Down Expand Up @@ -169,8 +169,8 @@ def api_get_host_history():


@api.route('/api/v1/getRecentScans', methods=['GET', 'OPTIONS'])
@check_for_deprecation_override_header
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers(cors=True)
def api_get_recent_scans():
try:
Expand All @@ -192,8 +192,8 @@ def api_get_recent_scans():

# TODO: Deprecate
@api.route('/api/v1/getScannerStates', methods=['GET', 'OPTIONS'])
@check_for_deprecation_override_header
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers(cors=True)
def api_get_scanner_states():
stats = database.select_scan_scanner_statistics(verbose=False)
Expand All @@ -202,8 +202,8 @@ def api_get_scanner_states():


@api.route('/api/v1/__stats__', methods=['GET', 'OPTIONS'])
@check_for_deprecation_override_header
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers(cors=True)
def api_get_scanner_stats():
pretty = True if request.args.get('pretty', '').lower() == 'true' else False
Expand Down Expand Up @@ -271,8 +271,8 @@ def api_get_scanner_stats():


@api.route('/api/v1/getScanResults', methods=['GET', 'OPTIONS'])
@check_for_deprecation_override_header
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers(cors=True)
@sanitized_api_response
def api_get_scan_results():
Expand Down Expand Up @@ -302,8 +302,8 @@ def api_get_scan_results():


@api.route('/contribute.json', methods=['GET'])
@check_for_deprecation_override_header
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers()
def contribute_json():
__dirname = os.path.abspath(os.path.dirname(__file__))
Expand Down
3 changes: 2 additions & 1 deletion httpobs/website/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from flask import Flask

from httpobs.conf import API_PORT, API_PROPAGATE_EXCEPTIONS, DEVELOPMENT_MODE
from httpobs.website import add_response_headers
from httpobs.website import add_response_headers, add_sunset_headers
from httpobs.website.api import api
from httpobs.website.monitoring import monitoring_api

Expand All @@ -21,6 +21,7 @@ def __exit_with(msg: str) -> None:


@app.route('/')
@add_sunset_headers()
@add_response_headers()
def main() -> str:
return 'Welcome to the HTTP Observatory!'
Expand Down

0 comments on commit 51ac0db

Please sign in to comment.