Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs inconsistency between Plug moduledoc and Plug.run #1201

Closed
wojtekmach opened this issue Dec 29, 2023 · 1 comment
Closed

Docs inconsistency between Plug moduledoc and Plug.run #1201

wojtekmach opened this issue Dec 29, 2023 · 1 comment

Comments

@wojtekmach
Copy link
Contributor

wojtekmach commented Dec 29, 2023

In Plug moduledoc we have:

A function plug is any function that receives a connection and a set of options and returns a connection. Its type signature must be:

(Plug.Conn.t, Plug.opts) :: Plug.Conn.t

however in Plug.run doc we have:

(...) (Plug.Conn.t -> Plug.conn.t()) (...)

The plugs given here can be either a tuple, representing a module plug and their options, or a simple function that receives a connection and returns a connection.

I'm not sure how, if at all, solve this inconsistency given the vast majority of plugs are modules with call/2 and functions called by plug macro which then need to be of arity 2.

@josevalim
Copy link
Member

The arity/1 makes sense from Plug.run/1 point of view, there are no options to pass around, so they have to be captured inside arity/1 functions. I don't think it is part of the Plug contract, so I don't think Bandit should support it because of Plug (it is their own call).

You can always have {Plug.Call, &fun/1} though and pass that to Bandit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants