Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Coronon
Copy link
Contributor

@Coronon Coronon commented Feb 25, 2024

Enhancing Contextual Awareness in ProxyHandler

While this library performs admirably, a critical aspect is lacking in my view: context between handler calls.

In my application, it's imperative to discern which connection is presently managed in each call. Although one could resort to context.AfterFunc(ctx, fun) within ProxyHandler.Init, it proves impractical and undermines the purpose of the ProxyHandler.Close function. This PR introduces the capability to enrich the context with pertinent values, enabling the tracking of requests throughout their lifecycle and facilitating appropriate actions at each stage.

I trust you find these adjustments beneficial. Keep up the exceptional work! 😊

@firefart
Copy link
Owner

Hi, thanks for the PR!
Just out of curiosity, why not store the value in the proxy handler struct itself from init? Is there a particular usecase to store it in the context itself I am missing here?

@Coronon
Copy link
Contributor Author

Coronon commented Feb 27, 2024

Currently, the proxy handler struct is initialized once for the lifetime of the proxy server. However, I aim to associate state on a per-request basis. Storing such data within the handler struct necessitates a unique, hashable key for each request. Regrettably, within the current implementation, I am unaware of any suitable mechanism to differentiate between requests.

@firefart firefart merged commit 43333a4 into firefart:main Mar 10, 2024
@firefart
Copy link
Owner

Thanks! Released v0.4.2

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