mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2025-08-23 14:23:05 +00:00
refactor: refactor HTTP client setup to enhance configuration flexibility (#47)
- Refactor HTTP client initialization to always create a custom http.Client - Move TLS config modification into the default HTTP client when insecure flag is set - Ensure the HTTP client is always included in client options Signed-off-by: appleboy <appleboy.tw@gmail.com> Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/47 Co-authored-by: appleboy <appleboy.tw@gmail.com> Co-committed-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
@@ -22,19 +22,20 @@ func Client() *gitea.Client {
|
|||||||
if client != nil {
|
if client != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
httpClient := &http.Client{
|
||||||
|
Transport: http.DefaultTransport,
|
||||||
|
}
|
||||||
|
|
||||||
opts := []gitea.ClientOption{
|
opts := []gitea.ClientOption{
|
||||||
gitea.SetToken(flag.Token),
|
gitea.SetToken(flag.Token),
|
||||||
}
|
}
|
||||||
if flag.Insecure {
|
if flag.Insecure {
|
||||||
httpClient := &http.Client{
|
httpClient.Transport.(*http.Transport).TLSClientConfig = &tls.Config{
|
||||||
Transport: &http.Transport{
|
InsecureSkipVerify: true,
|
||||||
TLSClientConfig: &tls.Config{
|
|
||||||
InsecureSkipVerify: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
opts = append(opts, gitea.SetHTTPClient(httpClient))
|
|
||||||
}
|
}
|
||||||
|
opts = append(opts, gitea.SetHTTPClient(httpClient))
|
||||||
if flag.Debug {
|
if flag.Debug {
|
||||||
opts = append(opts, gitea.SetDebugMode())
|
opts = append(opts, gitea.SetDebugMode())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user