Documentation ¶
Overview ¶
HTTP Client which handles generic error routing and marshaling
Index ¶
- Variables
- func AddAuthentication(c HttpClientConfig, req *http.Request)
- func AddDefaultHeaders(req *http.Request)
- type HttpClient
- func (h *HttpClient) Configuration() HttpClientConfig
- func (h *HttpClient) CreateHttpRequest(method, urlStr string, body io.Reader) (*http.Request, error)
- func (h *HttpClient) HttpDelete(url string, data interface{}, result interface{}) *Response
- func (h *HttpClient) HttpGet(url string, result interface{}) *Response
- func (h *HttpClient) HttpPost(url string, data interface{}, result interface{}) *Response
- func (h *HttpClient) HttpPut(url string, data interface{}, result interface{}) *Response
- func (h *HttpClient) Unwrap() *http.Client
- type HttpClientConfig
- type Method
- type Request
- type Response
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // invalid or error response ErrorInvalidResponse = errors.New("Invalid response from Remote") // some resource does not exists ErrorNotFound = errors.New("The resource does not exist") // Generic Error Message ErrorMessage = errors.New("Unknown error message was captured") // Not Authorized ErrorNotAuthorized = errors.New("Not Authorized to perform this action - Status: 403") // Not Authenticated ErrorNotAuthenticated = errors.New("Not Authenticated to perform this action - Status: 401") )
Functions ¶
func AddAuthentication ¶ added in v0.9.2
func AddAuthentication(c HttpClientConfig, req *http.Request)
func AddDefaultHeaders ¶ added in v0.9.2
Types ¶
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
func DefaultHttpClient ¶ added in v0.8.3
func DefaultHttpClient() *HttpClient
func NewHttpClient ¶
func NewHttpClient(config HttpClientConfig) *HttpClient
func (*HttpClient) Configuration ¶ added in v0.9.2
func (h *HttpClient) Configuration() HttpClientConfig
func (*HttpClient) CreateHttpRequest ¶ added in v0.9.2
func (h *HttpClient) CreateHttpRequest(method, urlStr string, body io.Reader) (*http.Request, error)
Creates a net/http Request and associates default headers and authentication parameters
func (*HttpClient) HttpDelete ¶
func (h *HttpClient) HttpDelete(url string, data interface{}, result interface{}) *Response
func (*HttpClient) HttpGet ¶
func (h *HttpClient) HttpGet(url string, result interface{}) *Response
func (*HttpClient) HttpPost ¶
func (h *HttpClient) HttpPost(url string, data interface{}, result interface{}) *Response
func (*HttpClient) HttpPut ¶
func (h *HttpClient) HttpPut(url string, data interface{}, result interface{}) *Response
func (*HttpClient) Unwrap ¶ added in v0.9.2
func (h *HttpClient) Unwrap() *http.Client
type HttpClientConfig ¶
type HttpClientConfig struct { sync.RWMutex // Http Basic Auth Username HttpUser string // Http Basic Auth Password HttpPass string // Http Authorization Token HttpToken string // Request timeout RequestTimeout int // TLS Insecure Skip Verify TLSInsecureSkipVerify bool }
func NewDefaultConfig ¶
func NewDefaultConfig() *HttpClientConfig
Click to show internal directories.
Click to hide internal directories.