Monviech / os-caddy-plugin

Caddy Plugin with GUI for OPNsense
Other
38 stars 0 forks source link

Creating an index for handles so their position can be changed #64

Closed Monviech closed 8 months ago

Monviech commented 8 months ago

Right now, handles are saved in the config.xml in the same order they have been created. The Caddyfile template iterates over the config.xml and then creates the Caddyfile in the same order the items are presented in the config.xml.

This makes the usability challenging if anybody uses more than just empty catch-all handles, since the order of the handles is crucial for expected functionality of them.

Possible fixes:

This one is rather challenging since there is no standard functionality for it that I can import, so I have to write an own solution for that.

For now, the creation time of items sets their position. So if an item should be moved to the end, it can be cloned and the original item deleted.

Monviech commented 8 months ago

I have decided against the index since like 99% of the time it's not needed. I improved the logic of the Caddyfile to always place empty handles last. Most of the time, only catch-all handles are defined anyways.

For all the other handles like /example/ or /foo/bar/ it's very unlikely that a usecase needs precise order to prevent them from overlapping with each other. A user who needs very precise handle definitions with very accurate processing order could use the custom Caddyfile import paths.

I think for most usecases, the automatic distinction between empty handles and populated handles will be enough.