salvo-rs/salvo

Rename Affix

domenkozar opened this issue · 6 comments

I've been searching for sharing data between application startup with each handler and I've completely missed Affix middleware.

Naming it something like Config or SharedData or ConfigDepot would make it easier to spot.

Thanks for the suggestion.
This middleware has been around for a long time, and I don't think there's much benefit in renaming it unless there's a very suitable word.

Config, SharedData, ConfigDepot don't seem to express its meaning well.

@chrislearn, @domenkozar is right. It also took me forever to learn how to share data between handlers or middleware. It's possible others will also find a hard time learning how to share data between handlers.
Before finding out about Affix, I had to create a custom impl handler for a custom AppState struct using #[handler] and then use it in a hoop.

Config, SharedData, ConfigDepot don't seem to express its meaning well.

In my opinion DepotState, AppState, AffixConfig, or AffixState will also be a good name replacement to Affix.

Thanks.

I prefer AddonState or AffixState, what do you think? @clarnx @domenkozar

@chrislearn thanks for the feedback. I think AffixState is fine since it indicates the attaching of a state.