elazarl / goproxy

An HTTP proxy library for Go
BSD 3-Clause "New" or "Revised" License
5.98k stars 1.09k forks source link

Refactor context to use golang's context #227

Open AlmogBaku opened 7 years ago

AlmogBaku commented 7 years ago

The current proxycontext is limited(i.e. UserData is in use and we can't use it to attach extra data).

Refactoring the context to use the golang's context should solve a lot of issues(or potential issues) and to bring consistency with the community's context.

elazarl commented 7 years ago

I'm not really sure why UserData isn't good enough, you can attach whatever you want to it. If you want to attach something to it, you can simply attach

struct { somethingA A somethingB B }

Or am I missing something?

What exactly do you purpose?

On Tue, Jun 27, 2017 at 12:58 PM, Almog Baku notifications@github.com wrote:

The current proxycontext is limited(i.e. UserData is in use and we can't use it to attach extra data).

Refactoring the context to use the golang's context should solve a lot of issues(or potential issues) and to bring consistency with the community's context.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/elazarl/goproxy/issues/227, or mute the thread https://github.com/notifications/unsubscribe-auth/AAP4ovLVjFCmrKxpLmHH8mYMwBr3i_CXks5sINIqgaJpZM4OGZx_ .

AlmogBaku commented 7 years ago
  1. My objective is to put on the context the information about the user. Also, I suggest we'll move to the generic context package in order to allow compatibility with different packages.

The current implementation of UserData does not allow different packages to use this field because you need to put there a common struct that every package need to know how to put the information in. Usage of context package solves that by having a common interface for that.