Feature/lifecycle hooks - #514
Merged
regyssilveira merged 2 commits intoJul 10, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implementação de Lifecycle Hooks (onRequest, preParsing, preValidation, onSend, onResponse)
Descrição
Este Pull Request introduz suporte completo e nativo a ganchos de ciclo de vida (Lifecycle Hooks) no ecossistema Horse. Esses ganchos permitem interceptar e atuar sobre a requisição e a resposta em 5 fases distintas, garantindo flexibilidade para auditoria, modificações em trânsito e tratamento de erros.
Funcionalidades
onRequest: Executado antes de qualquer processamento da rota ou middleware.preParsing: Executado antes do parser de requisições de middlewares nativos.preValidation: Executado logo após a resolução da rota ativa na árvore de rotas, mas antes do primeiro middleware/endpoint local.onSend: Executado logo antes de o payload final (string ou bytes) ser despachado no socket, permitindo modificação em trânsito.onResponse: Executado na saída de forma garantida (via blocotry..finallycentralizado) de forma universal para 100% dos provedores (Indy, HttpSys, IOCP, CrossSocket, CGI, Apache, ISAPI).Compatibilidade de Roteadores
Os ganchos foram integrados nativamente em ambos os roteadores centrais do framework:
THorseRouterTree)THorseRadixRouter)Validação e Qualidade
Tests.Integration.LifecycleHooks.paspara validar os 5 ganchos, interrupção prematura e manipulação do payload.dcclinux64.exe).samples/.