如何实现request path的通配符匹配呢?

61 views
Skip to first unread message

Kelvin Kuo

unread,
Apr 10, 2019, 6:07:09 AM4/10/19
to openresty
我的需求是,openresty做一个ip拦截网关,同时我支持path白名单,可以让使用者灵活的配置可以忽略的path。比如  www.weibo.com/userinfo/*,  *.weibo.com/userinfo/。因为lua原生不支持正则表达式,我不能要求所有业务方都学习lua的string.find() 语法,所以,是否有简单的方法支持wildcard匹配呢?

ytl m

unread,
Apr 10, 2019, 6:09:44 AM4/10/19
to openresty
看下ngx.re.match或者ngx.re.find相关接口是不是满足你的需求呢

在 2019年4月10日星期三 UTC+8下午6:07:09,Kelvin Kuo写道:

Kelvin Kuo

unread,
Apr 11, 2019, 4:58:58 AM4/11/19
to openresty
谢谢,通配符对业务人员更友好,但是正则也可以接受把,就用ngx.re.match了。

along

unread,
Apr 11, 2019, 5:03:58 AM4/11/19
to openresty
不客气的,用ngx.re.match的时候要注意性能哦

在 2019年4月11日星期四 UTC+8下午4:58:58,Kelvin Kuo写道:

Kelvin Kuo

unread,
Apr 11, 2019, 5:05:38 AM4/11/19
to openresty
“jo”是吧?
Reply all
Reply to author
Forward
0 new messages