RFC: Further reduction of controller boilerplate (Phase 2 of removing ja_resource)
还没有人认领这个 Issue。
评估
调研方向
首先阅读 CodeCorpsWeb 模块的 def controller quote 块、router.ex,以及 action_fallback、DataToAttributes 和 IdsToIntegers 的 controller 声明。追踪 API 接口和 webhook 接口当前的差异。完成的标准是就提出的三个改动作出决定并记录下来,不能隐藏行为,也不能将错误的 plugs 应用于 webhook。
由索引模型根据 Issue 内容生成。
描述
We could do the following 3 items to further reduce boilerplate in controllers.
However, while boilerplate is reduced, all 3 of these actions also hide behavior which we may not want to hide.
Remove action_fallback CodeCorpsWeb.FallbackController from all controllers and instead move it into the CodeCorpsWeb module into the def controller quote block
This makes sense at first glance, but it does also put all of our controllers into basically the same basket, regardless of them being actual API controllers, or just webhook handlers, or something else entirely.
Unfortunately, it is not currently possible to specify multiple action fallbacks for the same controller, which would be an argument for doing this, since it would allow simultaneously specifying global and group-specific fallbacks.
Remove plug CodeCorpsWeb.Plug.DataToAttributes from all controllers and move it into router.ex into the :api pipeline.
We would have to separate our general api pipeline and the part of the pipeline that handles github and sprite webhooks, since we don't want this plug in that part, but it would make sense to do so anyway, since they are, in fact, different parts of the "interface".
Remove plug CodeCorpsWeb.Plug.IdsToIntegers from all controllers and move it into router.ex into the :api pipeline.
Basically same argument as above.
Really, these two plugs should be considered one pipeline, since their intention is to prepare and make sense of the data sent by our client.
@JoshSmith
What do you think? Overall, this would not take much time, maybe an hour, but I'm not really sure if it would help or hurt us.
- 主要语言
- Elixir
- 星标
- 234
- 派生
- 82
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
code-corps/code-corps-api 的其他 Issue
-
难度 5/5 一周以上 新手友好度 15/100
code-corps/code-corps-api#1385 ·
-
难度 3/5 1-2 天 新手友好度 25/100
code-corps/code-corps-api#1384 ·
-
难度 4/5 3-5 天 新手友好度 35/100
code-corps/code-corps-api#1383 · 2 条评论 ·
-
难度 3/5 1-2 天 新手友好度 35/100
code-corps/code-corps-api#1382 · 2 条评论 ·
-
Difficulty: Medium Skill: Elixir Time: 4 hours
code-corps/code-corps-api#1372 · 3 条评论 · 已指派 1 人 ·
查看 code-corps/code-corps-api 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 84/100
phoenixframework/phoenix#6847 ·
-
bug
难度 2/5 1-3 小时 新手友好度 64/100
-
难度 2/5 1-3 小时 新手友好度 78/100
-
moderation
难度 2/5 1-3 小时 新手友好度 82/100
beyond-all-reason/teiserver#1584 · 1 条评论 ·