MCPcopy
hub / github.com/minio/minio-go / privateNew

Function privateNew

api.go:253–345  ·  view source on GitHub ↗
(endpoint string, opts *Options)

Source from the content-addressed store, hash-verified

251}
252
253func privateNew(endpoint string, opts *Options) (*Client, error) {
254 // construct endpoint.
255 endpointURL, err := getEndpointURL(endpoint, opts.Secure)
256 if err != nil {
257 return nil, err
258 }
259
260 // Initialize cookies to preserve server sent cookies if any and replay
261 // them upon each request.
262 jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
263 if err != nil {
264 return nil, err
265 }
266
267 // instantiate new Client.
268 clnt := new(Client)
269
270 // Save the credentials.
271 clnt.credsProvider = opts.Creds
272
273 // Remember whether we are using https or not
274 clnt.secure = opts.Secure
275
276 // Save endpoint URL, user agent for future uses.
277 clnt.endpointURL = endpointURL
278
279 transport := opts.Transport
280 if transport == nil {
281 transport, err = DefaultTransport(opts.Secure)
282 if err != nil {
283 return nil, err
284 }
285 }
286
287 clnt.httpTrace = opts.Trace
288
289 // Instantiate http client and bucket location cache.
290 clnt.httpClient = &http.Client{
291 Jar: jar,
292 Transport: transport,
293 CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
294 return http.ErrUseLastResponse
295 },
296 }
297
298 // Sets custom region, if region is empty bucket location cache is used automatically.
299 if opts.Region == "" {
300 if opts.CustomRegionViaURL != nil {
301 opts.Region = opts.CustomRegionViaURL(*clnt.endpointURL)
302 } else {
303 opts.Region = s3utils.GetRegionFromURL(*clnt.endpointURL)
304 }
305 }
306 clnt.region = opts.Region
307
308 // Initialize bucket region cache.
309 clnt.bucketLocCache = &kvcache.Cache[string, string]{}
310

Callers 1

NewFunction · 0.85

Calls 3

GetRegionFromURLFunction · 0.92
getEndpointURLFunction · 0.85
IsV4Method · 0.80

Tested by

no test coverage detected