github.com/sap/cf-mta-plugin@v2.6.3+incompatible/clients/baseclient/base_client.go (about)

     1  package baseclient
     2  
     3  import (
     4  	"net/http"
     5  	"net/http/cookiejar"
     6  
     7  	"github.com/go-openapi/runtime"
     8  	"github.com/go-openapi/runtime/client"
     9  )
    10  
    11  var schemes = []string{"http", "https"}
    12  
    13  // BaseClient represents a base SLP client
    14  type BaseClient struct {
    15  	TokenFactory TokenFactory
    16  }
    17  
    18  // GetTokenFactory returns the authentication info
    19  func (c *BaseClient) GetTokenFactory() TokenFactory {
    20  	return c.TokenFactory
    21  }
    22  
    23  // SetTokenFactory sets the authentication info
    24  func (c *BaseClient) SetTokenFactory(tokenFactory TokenFactory) {
    25  	c.TokenFactory = tokenFactory
    26  }
    27  
    28  // NewHTTPTransport creates a new HTTP transport
    29  func NewHTTPTransport(host, url, encodedUrl string, rt http.RoundTripper) *client.Runtime {
    30  	// TODO: apply the changes made by Boyan here, as after the update of the dependencies the changes are not available
    31  	transport := client.New(host, url, encodedUrl, schemes)
    32  	transport.Consumers["text/html"] = runtime.TextConsumer()
    33  	transport.Transport = rt
    34  	jar, _ := cookiejar.New(nil)
    35  	transport.Jar = jar
    36  	return transport
    37  }