Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

RFC: Further reduction of controller boilerplate (Phase 2 of removing ja_resource)

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

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
停滞
技术栈
elixir
领域
api, backend

调研方向

首先阅读 CodeCorpsWeb 模块的 def controller quote 块、router.ex,以及 action_fallback、DataToAttributes 和 IdsToIntegers 的 controller 声明。追踪 API 接口和 webhook 接口当前的差异。完成的标准是就提出的三个改动作出决定并记录下来,不能隐藏行为,也不能将错误的 plugs 应用于 webhook。

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

描述

question RFC

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

贡献指南

打开贡献指南

从这里开始

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

code-corps/code-corps-api 的其他 Issue

查看 code-corps/code-corps-api 的全部 Issue

相似的 Issue

更多 Elixir Issue

把新 issue 发到你的邮箱

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