seanmonstar / warp

A super-easy, composable, web server framework for warp speeds.
https://seanmonstar.com/post/176530511587/warp
MIT License
9.61k stars 724 forks source link

Does the paths get resolved in order? #837

Open kingluo opened 3 years ago

kingluo commented 3 years ago

For example, if I have 1000 or more paths needed to be handled,

path1.or(path2).or(path3)...

Then for each HTTP request, it would search the handler path by path in order of path concat order? If the number of paths is large, then the performance would be worse?

Could warp handle the paths just like Nginx does?

http://nginx.org/en/docs/http/ngx_http_core_module.html#location

https://github.com/kingluo/luajit.io/blob/master/lib/ljio/http/init.lua#L905

First exact search in paths hash table, Second search longest prefix in paths prefix hash table, and last for regular pattern tables.

jxs commented 3 years ago

Hi, yeah warp resolves path's in order see here for how the path filter works, when it returns not_found if there is another path plugged via an or it is tried.

kingluo commented 3 years ago

The performance of warp would decrease a lot when a lot of URIs or combination. See here.