-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
refactor(confighttp): HTML page handlers into generic getPage function #4645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Bundle ReportBundle size has no change ✅ |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4645 +/- ##
==========================================
- Coverage 15.51% 15.50% -0.02%
==========================================
Files 94 94
Lines 19248 19186 -62
Branches 8907 8861 -46
==========================================
- Hits 2986 2974 -12
- Misses 14393 14995 +602
+ Partials 1869 1217 -652
Flags with carried forward coverage won't be shown. Click here to find out more.
|
edee013 to
1f0d6d4
Compare
Consolidated multiple individual HTML page handler functions into a single getPage function that serves different HTML files based on parameters. Updated server route bindings to use the new generic handler, reducing code duplication and improving maintainability.
Updated all HTTP handler functions to take const reference parameters for response and request objects, improving const-correctness and clarity. Introduced a helper for page handlers and refactored server route setup to use concise lambda expressions and handler typedefs, reducing code duplication and improving maintainability.
Introduced check_request_body_empty to validate that certain API endpoints receive no request body, replacing previous content-type checks where appropriate. This improves request validation and ensures correct client usage for endpoints that do not expect a body.
Updated function signatures in confighttp.cpp to ensure consistent spacing between type and parameter names, improving code readability and style consistency.
Refactors the generateExamples function to only include Content-Type headers and body parameters in cURL, JavaScript, and PowerShell examples when a request body is present. This prevents unnecessary headers and parameters in generated code samples for endpoints that do not require a body.
Add initial unit tests for confighttp using a real HTTPS client/server (tests/unit/test_confighttp.cpp). Update confighttp public API and types: add necessary includes (nlohmann::json, Simple-Web-Server), introduce HTTPS type aliases (https_server_t, resp_https_t, req_https_t), and declare helper functions (print_req, send_response, send_unauthorized, send_redirect, authenticate, not_found, bad_request, check_* utilities, getPage, etc.). Align implementations in src/confighttp.cpp with the header by removing default parameters from not_found, bad_request, and getPage signatures. These changes improve test coverage and clarify the confighttp interface.
1f0d6d4 to
691ff1b
Compare
|




Description
Consolidated multiple individual HTML page handler functions into a single getPage function that serves different HTML files based on parameters. Updated server route bindings to use the new generic handler, reducing code duplication and improving maintainability.
Updated all HTTP handler functions to take const reference parameters for response and request objects, improving const-correctness and clarity. Introduced a helper for page handlers and refactored server route setup to use concise lambda expressions and handler typedefs, reducing code duplication and improving maintainability.
Introduced check_request_body_empty to validate that certain API endpoints receive no request body, replacing previous content-type checks where appropriate.
Refactors the generateExamples javascript function for docs to only include Content-Type headers and body parameters in cURL, JavaScript, and PowerShell examples when a request body is present. This prevents unnecessary headers and parameters in generated code samples for endpoints that do not require a body.
Screenshot
Issues Fixed or Closed
Roadmap Issues
Type of Change
Checklist
AI Usage