github.com/blend/go-sdk@v1.20220411.3/r2/opt_scheme.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package r2
     9  
    10  import (
    11  	"net/url"
    12  
    13  	"github.com/blend/go-sdk/ex"
    14  )
    15  
    16  // OptScheme sets the url scheme.
    17  func OptScheme(scheme string) Option {
    18  	return func(r *Request) error {
    19  		if r.Request == nil {
    20  			return ex.New(ErrRequestUnset)
    21  		}
    22  		if r.Request.URL == nil {
    23  			r.Request.URL = &url.URL{}
    24  		}
    25  		r.Request.URL.Scheme = scheme
    26  		return nil
    27  	}
    28  }