-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Does this package support configuring a proxy? #2363
Comments
I believe this is possible, but don't have the details. Hopefully others can comment and provide you with what you need. |
@gmlewis thanks, for now, I have no idea to do it. if I figure it out, I will post it here. thanks. |
You need to configure the proxy in a new http.client and pass it as a parameter to your "github client" package main
import (
"context"
"fmt"
"log"
"github.com/google/go-github/v45/github"
"net/http"
"net/url"
)
func main() {
//creating the proxyURL
proxyStr := "<your-proxy-url>"
proxyURL, err := url.Parse(proxyStr)
if err != nil {
log.Println(err)
}
transport := &http.Transport{
Proxy: http.ProxyURL(proxyURL),
}
//adding the Transport object to the http Client
httpclient := &http.Client{
Transport: transport,
}
client := github.NewClient(httpclient)
// list public repositories for org "github"
opt := &github.RepositoryListByOrgOptions{Type: "public"}
repos, _, err := client.Repositories.ListByOrg(context.Background(), "github", opt)
if err != nil {
log.Fatal(err)
}
// If no error was returned, print the returned message
// to the console.
fmt.Println(repos)
} |
Thank you, @extravio ! Closing due to solution provided above: #2363 (comment) |
I want to use this package to au-create the issue in my repo. but my env is private, and we provide a proxy to access the internet. so I am not sure if I can configure a proxy with this package to call my github repo. thanks.
The text was updated successfully, but these errors were encountered: