Elixir 凤凰卫视API列表

Elixir 凤凰卫视API列表,elixir,phoenix-framework,Elixir,Phoenix Framework,我想要一个端点/api/api_endpoints/列出所有公共api端点。类似于mix phx.routes,但我只想列出如下内容 ... GET /api/users PUT /api/users/name ... 诸如此类的事情。我查看了文档,但没有看到任何列出路线的内容。没有内置任何内容,但对于像您希望的那样简单的内容,您可以随时滚动自己的路线。所有路由都作为Phoenix.router.Route stucts列表存储在路由器中。例如,在名为“住宅”的项目中: 您可以映射它们,提取动

我想要一个端点/api/api_endpoints/列出所有公共api端点。类似于mix phx.routes,但我只想列出如下内容

...
GET /api/users
PUT /api/users/name
...

诸如此类的事情。我查看了文档,但没有看到任何列出路线的内容。

没有内置任何内容,但对于像您希望的那样简单的内容,您可以随时滚动自己的路线。所有路由都作为Phoenix.router.Route stucts列表存储在路由器中。例如,在名为“住宅”的项目中:

您可以映射它们,提取动词和路径,并根据需要显示它们


这就是mix phx.routes的工作原理,如果你想知道的话,

目前Phoenix中没有内置任何东西可以做到这一点。但是,您可以使用类似的库来完成类似的任务。谢谢,我将看一看,因为我刚刚开始在同一个项目中使用swagger。还要注意,_routes__函数是一个内部API,因此可以在不通知的情况下更改或删除它。@JustinWood,您对非内部API有什么建议吗?从路由上看,mix phx.routes会使用它来生成输出。此外,Phoenix.Router.consoleformter.format/1可以用于生成与$mix phx.routes相同的字符串输出。当它访问一个内部API时,我将把它标记为一个答案。Thx@mario。
iex(1)> ResidentialWeb.Router.__routes__
[%Phoenix.Router.Route{assigns: %{}, helper: "page", host: nil, kind: :match,
opts: :index, path: "/", pipe_through: [:browser],
plug: ResidentialWeb.PageController, private: %{}, verb: :get},
%Phoenix.Router.Route{assigns: %{}, helper: "user", host: nil, kind: :match,
opts: :index, path: "/users", pipe_through: [:browser],
plug: ResidentialWeb.UserController, private: %{}, verb: :get},
%Phoenix.Router.Route{assigns: %{}, helper: "user", host: nil, kind: :match,
opts: :edit, path: "/users/:id/edit", pipe_through: [:browser],
plug: ResidentialWeb.UserController, private: %{}, verb: :get},