Add request lifecycle hooks to support extensibility

未关闭
#7,607 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
12/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
活跃
领域
backend

调研方向

This is a design proposal, not a located change: it asks for enter/exit hooks around the app, router and route stages the request passes through, plus possibly middleware auto-wrapping. Start by reading how the router dispatches through its layers and where a request leaves one layer for another, then write up the hook points and their ordering/error semantics as a proposal for maintainers to agree on before any code. Done here means an accepted design (likely an RFC or discussion) rather than a patch, so it is not a starting point for a first contribution.

由索引模型根据 Issue 内容生成。

描述

There are a number of features that I would like express to support. Things that I personally feel would improve ergonomics and ease of use. However, many of them involve a decision about a choice in direction and behavior that I suspect express would decline to make on behalf of users as a whole. For instance: I would like to support automatic output serialization based on content type and registered serializers.

I am willing to implement things like this for my own use, but I find myself stymied by the lack of hooks into the express routing process. While I can store a stack of scopes with registered serializers on the request, I have no way to guarantee the stack unwinds if the processing jumps to another route or router.

A robust system of hooks would not only support my own personal extensions, but enable an ecosystem of behavioral plugins.

The top lifecycle hooks that would help me personally are enter/exit hooks for app/router/route. Though there are probably other useful points that I am simply not thinking of at the moment.

I would also find the ability to auto-wrap middleware useful, but I don't know if that is too much to ask for at the moment.

主要语言
JavaScript
星标
69.7k
派生
25.7k
平均合并
2 天 9 小时
30 天内合并 PR
4

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

expressjs/express 的其他 Issue

查看 expressjs/express 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。