-
Notifications
You must be signed in to change notification settings - Fork 610
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
Decoupling from Gorilla Mux #131
Comments
+1 |
@rickb777 there is a minor difference in the first code what on first looks like the same: @markbates binding against mux is indeed a problem , but I know when we would change this it would break applications using this default behavior . Any thoughts on how to decouple this? I also changed the GetProviderName function to a custom function to do my own implementation when using Macaron , but this does indeed not remove the gorilla/mux dependency on the project. |
This coupling has been there for a few years, and to remove it would break existing apps. If someone can figure out a way to do this would breaking backward compatibility I'm all ears. |
@markbates what about a v2 sub-package in-line with Go module design? Some common functionality could be moved into an internal package and exported by both while the v2 package could be built without being coupled to gorilla/mux and the old package could remain as is. |
As for the backwards compatible approach Both gorilla/mux and httperouter can use |
Has there been any follow-up on this? Would be nice to remove the dependency on gorilla packages (both Would @markbates or other maintainers be open to supporting something like this? I could potentially help with PR's and whatnot. EDIT: /cc @techknowlogick |
See #552 |
In recent months, gothic.go has become coupled to gorilla/mux. See lines 176 onward
Firstly, note that
req.URL.Query().Get(":provider")
is possibly called twice (this may be a mistake).Secondly,
mux.Vars(req)["provider"]
is specific to gorilla/mux. I happen to use julienschmidt/httprouter and I'd quite like to decouple from gorilla/mux dependency, which I don't need in my codebase.So, perhaps the package
gothic
is really two things: (a) it provides the main API forgoth
and (b) it provides gorilla/mux lookup of the provider variable. Combining these is unfortunate because it reduces the flexibility of the package. [There is a third concern: storage of state in the session; however I'm content to leave this unchanged.]There are several possible options to reduce this coupling. The simplest I can think of is to do away with the
GetProviderName
method (andgetProviderName
) and change the signature ofCompleteUserAuth
to take an additionalproviderName string
parameter.It would then be quite easy to have another function that wraps
CompleteUserAuth
as a standardhttp.HandlerFunc
, along with the gorilla/mux providerName expression - this would need to be in a different package so that gorilla/mux drops out of the imports list (note that gorilla/mux is in the list of imports and this is the key difficulty).It would also be easy to implement different integrations with other routing libraries, which Is what I would need.
My workaround for this is to make a copy of gothic.go in my own codebase and with the necessary alteration I've described. But I'd prefer not to have to duplicate the code.
The text was updated successfully, but these errors were encountered: