URI自定义匹配模板
Posted: Tue Jul 06, 2021 7:49 am
ESP32做 web服务器使用,使用配置条件: 默认可以匹配以xxx开始的部分,匹配如下:
如果我要实现如下这种匹配结构,匹配函数该怎么写?
文档说,参考httpd_uri_match_func_t函数原型说明
原型如下:
这三个参数的含义没看懂
Code: Select all
config.uri_match_fn = httpd_uri_match_wildcard;
Code: Select all
* Example:
* - * matches everything
* - /foo/? matches /foo and /foo/
* - /foo/\* (sans the backslash) matches /foo/ and /foo/bar, but not /foo or /fo
* - /foo/?* or /foo/\*? (sans the backslash) matches /foo/, /foo/bar, and also /foo, but not /foox or /fo
*
* The special characters "?" and "*" anywhere else in the template will be taken literally.
Code: Select all
/*.html
/*.css
原型如下:
Code: Select all
typedefbool (*httpd_uri_match_func_t)(const char *reference_uri, const char *uri_to_match, size_t match_upto)
Function prototype for URI matching.
Return
true on match
Parameters
[in] reference_uri: URI/template with respect to which the other URI is matched
[in] uri_to_match: URI/template being matched to the reference URI/template
[in] match_upto: For specifying the actual length of uri_to_match up to which the matching algorithm is to be applied (The maximum value is strlen(uri_to_match), independent of the length of reference_uri)