32ea23906f
- also component renaming Signed-off-by: Peter Siegmund <developer@mars3142.org>
1.2 KiB
1.2 KiB
description, name, applyTo
| description | name | applyTo |
|---|---|---|
| Use when implementing or changing ESP-IDF HTTP handlers, REST routes, captive portal flows, static file serving, CORS handling, or WebSocket-adjacent API behavior in bifrost. | Bifrost (API Server) Instructions | components/bifrost/**/*.{c,h} |
Bifrost (API Server) Guidelines
- Keep handler registration order stable in api_handlers.c:
- specific /api routes
- wildcard API routes
- captive-portal detection routes
- OPTIONS /api/*
- static fallback /* last
- Preserve response consistency by reusing helper functions:
- set_cors_headers
- send_json_response
- send_error_response
- In api_server.c, initialize WebSocket handling before registering API handlers.
- Keep static asset behavior HTTP-correct:
- content type by original file type
- CORS headers for browser usage
- Content-Encoding: gzip when serving .gz assets
- Prefer localized changes in bifrost only; avoid cross-component coupling for state changes.
- For state updates, use message_manager_post instead of direct control flow into other components.
- Add clear ESP_LOGI/W/E messages with the local TAG for new request paths and error branches.