Skip to content

Implement a more comprehensive way to get connection information #1269

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mtrudel
Copy link
Contributor

@mtrudel mtrudel commented May 13, 2025

DO NOT MERGE (YET). Presented for feedback on the API ergonomics. Once we get alignment on the approach here, I'll get corresponding PRs queued up for Bandit and Plug.Cowboy to go out at the same time.

Scope of changes:

  • Add c:Plug.Conn.Adapter.get_connection_data/1
  • Remove c:Plug.Conn.Adapter.get_peer_data/1 from Adapter behaviour
  • Add Plug.Conn.get_connection_data/1
  • Implement Plug.Conn.get_peer_data in terms of get_connection_data/1

…a conn

* Add c:Plug.Conn.Adapter.get_connection_data/1
* Remove c:Plug.Conn.Adapter.get_peer_data/1 from Adapter behaviour

* Add Plug.Conn.get_connection_data/1
* Implement Plug.Conn.get_peer_data in terms of get_connection_data/1
@mtrudel
Copy link
Contributor Author

mtrudel commented May 13, 2025

Hrm. Looking into the work required to implement this in Cowboy, it's not insignificant. Cowboy easily provides all of the existing info in peer_data, but basically nothing else (I suspect that this is probably why the existing Plug.Conn.Adapter contract looks the way it does). It'd be a whole set of kinda subtle PRs all the way up to Ranch to get this information sourced, for what amounts to a pretty niche use case. Not entirely sure this is a good use of effort, TBH.

WDYT?

@ns-blee
Copy link

ns-blee commented May 19, 2025

Out of curiosity here... It is not possible to do an adapter check, return nil if Cowboy, and the value if Bandit? Or is the expectation that it will remain agnostic? If so, is there not some way to expose the methods and allow the user to do the adapter check, if needed, though implied? Without access I will be forced to use a proxy and handle TLS termination there so I can inject the values in the stream...

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

Successfully merging this pull request may close these issues.

2 participants