#pragma once #include #include "httpd-types.h" #define HTTPD_ESPFS_TOKEN_LEN 64 /** * The template substitution callback. * Returns CGI_MORE if more should be sent within the token, CGI_DONE otherwise. * If token is NULL, we're doing a clean-up at the end of the request, this is a good place to free any user data. */ typedef httpd_cgi_state (* TplCallback)(HttpdConnData *conn, const char *token); /** * Serve a static file from EspFs. The file name is in the first CGI arg. If NULL, the URI is used as a file name. * * @param connData * @return CGI state */ httpd_cgi_state cgiEspFsStaticFile(HttpdConnData *connData); /** * Serve a template from EspFs. * * - The first arg is the TplCallback replacer function. * - The second arg is the file name, if given, otherwise the URI is used as a file name * * @param conn * @return CGI state */ httpd_cgi_state cgiEspFsTemplate(HttpdConnData *conn); /** * Send template substitution string with known len * * @param td - template data * @param str - string to send * @param len - string len * @return 1 = OK */ int tplSendN(HttpdConnData *conn, const char *str, size_t len); /** * Send template substitution string (use strlen) * * @param tpd - template data * @param str - string to send * @return 1 = OK */ static inline int tplSend(HttpdConnData *conn, const char *str) { return tplSendN(conn, str, strlen(str)); }