apostrophecms / apostrophe-redirects

Allows admins to create redirects within an Apostrophe site
2 stars 2 forks source link

Add a server-side event when a redirect is found #30

Open abea opened 3 years ago

abea commented 3 years ago

The problem to solve

There's no good way to take additional actions, such as tracking redirect use, before a redirect executes

Proposed solution

We emit a Promise event after a matching redirect is found and include both the original URL and its destination.

Alternatives

We could break up the middleware into methods more so they could be edited with the super pattern.

Additional context

This came up from a question in Discord: https://discord.com/channels/517772094482677790/517782236800745495/837372820182401024

boutell commented 3 years ago

That would work. Emitting an object would allow modification of the destination property by the event handlers.

On Thu, Apr 29, 2021 at 1:42 PM Alex Bea @.***> wrote:

The problem to solve

There's no good way to take additional actions, such as tracking redirect use, before a redirect executes Proposed solution

We add a Promise event after a matching redirect is found and emit both the original URL and its destination. Alternatives

We could break up the middleware into methods more so they could be edited with the super pattern. Additional context

This came up from a question in Discord: https://discord.com/channels/517772094482677790/517782236800745495/837372820182401024

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/apostrophecms/apostrophe-redirects/issues/30, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAH27MPZ5PY4ACNNTPLZPLTLGK7XANCNFSM432LVDXQ .

--

THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER APOSTROPHECMS | apostrophecms.com | he/him/his