viz-rs / path-tree

path-tree is a lightweight high performance HTTP request router for Rust
Apache License 2.0
118 stars 17 forks source link

Add new node kinds #27

Open fundon opened 2 years ago

fundon commented 2 years ago
fundon commented 2 years ago

:name([0-9]+)

mbodmer commented 4 months ago

For my MQTT usecase I have shared here: https://github.com/viz-rs/path-tree/pull/41#issuecomment-2152654653 there would be the need to have a wildcard which excludes the trailing / when matching.

I have used a named wildcard like this: MQTT/multilevel/:value*.

this matches topics like:

MQTT/multilevel/ -> value: "" MQTT/multilevel/a -> value: "a" MQTT/multilevel/a/b -> value: "a/b"

and so on, but the MQTT specification also requires matching of:

MQTT/multilevel

which would result in including the / in the values above and MQTT/multilevel would be the empty string.

This was and is still "good enough" for me, but it would be nice to have a dedicated matcher or option for this usecase also.

mbodmer commented 4 months ago

Another nice thing would be an optional "root node", which would allow having routes which don't need a common first character.

fundon commented 4 months ago

Another nice thing would be an optional "root node", which would allow having routes which don't need a common first character.

This was supported in very early versions.

This was and is still "good enough" for me, but it would be nice to have a dedicated matcher or option for this usecase also

I will consider adding this feature.

mbodmer commented 4 months ago

I know MQTT is not the intended use case, but since the router is very versatile it almost supports it :-) so i just wanted to drop it here for reference. Of course it is up to you to decide the future direction of the project.