// BuildRequest creates a new http.Request for the given URI.
BuildRequest creates a new http.Request for the given URI.
// BuildRequest creates a new http . Request for the given URI .
func (cfd *CloudflaredMethod) BuildRequest(client *http.Client, uri *url.URL) (*http.Request, error) {
	if uri.Scheme != "cfd+https" {
		cfd.mwriter.Log(fmt.Sprintf("Invalid URI Scheme: %q", uri.Scheme))
		return nil, fmt.Errorf("invalid URI Scheme: '%s'", uri.Scheme)
	}
	uri.Scheme = "https"
	ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
	defer cancel()
	cfd.mwriter.Log(fmt.Sprintf("Getting JWT for %v", uri))
	token, err := access.GetToken(ctx, uri, cfd.datapath, true, cfd.urlwriter)
	if err != nil {
		return nil, err
	}
	cfd.client.Transport = access.NewTransport(token, cfd.transport)
	req, err := http.NewRequest("GET", uri.String(), nil)
	if err != nil {
		return nil, err
	}
	return req, nil
}
func ( cfd * CloudflaredMethod ) BuildRequest ( client * http . Client , uri * url . URL ) ( * http . Request , error ) { if uri . Scheme != " " { cfd . mwriter . Log ( fmt . Sprintf ( " " , uri . Scheme ) ) return nil , fmt . Errorf ( " " , uri . Scheme ) } uri . Scheme = " " ctx , cancel := context . WithTimeout ( context . Background ( ) , 45 * time . Second ) defer cancel ( ) cfd . mwriter . Log ( fmt . Sprintf ( " " , uri ) ) token , err := access . GetToken ( ctx , uri , cfd . datapath , true , cfd . urlwriter ) if err != nil { return nil , err } cfd . client . Transport = access . NewTransport ( token , cfd . transport ) req , err := http . NewRequest ( " " , uri . String ( ) , nil ) if err != nil { return nil , err } return req , nil }
BuildRequest creates a new http.Request for the given URI.
BuildRequest creates a new http . Request for the given URI .
// TODO: Allow configuring this