feat(esp_http_server): Added pre handshake callback for websocket

1. If the user wants authenticate the request, then user needs to do
this before upgrading the protocol to websocket.
2. To achieve this, added pre_handshake_callack, which will execute
before handshake, i.e. before switching protocol.
This commit is contained in:
hrushikesh.bhosale
2025-07-18 15:14:33 +05:30
parent adfa52c442
commit 415a05a6a5
7 changed files with 139 additions and 3 deletions
@@ -458,6 +458,14 @@ typedef struct httpd_uri {
* Pointer to subprotocol supported by URI
*/
const char *supported_subprotocol;
#if CONFIG_HTTPD_WS_PRE_HANDSHAKE_CB_SUPPORT || __DOXYGEN__
/**
* Pointer to WebSocket pre-handshake callback. This will be called before the WebSocket handshake is processed,
* i.e. before the server responds with the WebSocket handshake response or before switching to the WebSocket handler.
*/
esp_err_t (*ws_pre_handshake_cb)(httpd_req_t *req);
#endif
#endif
} httpd_uri_t;