#ifndef ZK_HANDLERS_H #define ZK_HANDLERS_H #include "zk_auth.h" #include #include #include #include #include #include #include #include #include #include #include #include #include // Global ZK Auth instance (to be initialized in main) extern ZKAuth zk_auth; extern httpd_handle_t server_http; // API endpoint: Get device identity static esp_err_t handle_zk_identity(httpd_req_t *req) { char *json_response = zk_auth.get_identity_json(); if (json_response == NULL) { httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR, "Failed to get identity"); return ESP_FAIL; } httpd_resp_set_type(req, "application/json"); httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); httpd_resp_sendstr(req, json_response); free(json_response); return ESP_OK; } // API endpoint: Process unlock request // Handle CORS preflight // Register all ZK auth routes to the HTTP server void register_zk_handlers(httpd_handle_t server) { httpd_uri_t identity_uri = {.uri = "/api/identity", .method = HTTP_GET, .handler = handle_zk_identity, .user_ctx = NULL}; httpd_register_uri_handler(server, &identity_uri); } #endif // ZK_HANDLERS_H