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

OAuth package goth does not work #26

Closed
dc0d opened this issue Mar 12, 2016 · 6 comments
Closed

OAuth package goth does not work #26

dc0d opened this issue Mar 12, 2016 · 6 comments

Comments

@dc0d
Copy link

dc0d commented Mar 12, 2016

Apparently query parameters which should be available via req.URL.Query().Get("some-key") get removed by httptreemux. Not that this is necessarily a bug, but if this is by design, one should be aware of that.

@dimfeld
Copy link
Owner

dimfeld commented Mar 12, 2016

Can you provide some code sample? My package doesn't modify req.URL so offhand I'm not sure why you would be seeing this problem.

@dc0d
Copy link
Author

dc0d commented Mar 12, 2016

Thansk for the reply! I've just replaced package github.com/gorilla/pat with httptreemux in goth's own example; https://github.com/markbates/goth/blob/master/examples/main.go.

@dimfeld
Copy link
Owner

dimfeld commented Mar 12, 2016

Ok, thanks. I may not be able to look into this for a week or so, but I definitely will figure out what's going on there.

@dc0d
Copy link
Author

dc0d commented Mar 13, 2016

My idiocy! I can't check it right now; but I remembered the query parameter was not actually got a value in my code. I'll check & report back.

@dc0d
Copy link
Author

dc0d commented Mar 13, 2016

Using this method from pat:

func registerVars(r *http.Request, vars map[string]string) {
    parts, i := make([]string, len(vars)), 0
    for key, value := range vars {
        parts[i] = url.QueryEscape(":"+key) + "=" + url.QueryEscape(value)
        i++
    }
    q := strings.Join(parts, "&")
    if r.URL.RawQuery == "" {
        r.URL.RawQuery = q
    } else {
        r.URL.RawQuery += "&" + q
    }
}

I've added missing parameters. It's that pat adds parameters as query params to req.URL.RawQuery automatically (& apparently some packages like goth use query parameters). pat does this to make a query-included url look like a REST one.

Excuse me for any inconveniences.

@dimfeld
Copy link
Owner

dimfeld commented Mar 13, 2016

Oh that's interesting. I'll add a section to the README pointing out this difference. Thanks for following up on this!

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