bhttp

package
v0.0.0-...-5e392d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPCaller

func NewHTTPCaller(log *logrus.Entry) *httpCaller

NewHTTPCaller HTTPCaller's constructor

func NewHTTPConnection

func NewHTTPConnection(url string) *httpConnection

NewHTTPConnection Default configuration for http connection

func Retry

func Retry(f func(httpConnection) HTTPResponse, args httpConnection, log *logrus.Entry) *retryHTTP

Retry It will retry all failure calls for the given certain of times

Types

type ActualResponse

type ActualResponse struct {
	Error      error
	StatusCode int
	Body       string
}

ActualResponse To handle if user given urls

type HTTPInterface

type HTTPInterface interface {
	// To handle http get calls
	Get(httpConnection) HTTPResponse

	// To handle http post calls
	Post(httpConnection) HTTPResponse

	// To handle http put calls
	Put(httpConnection) HTTPResponse

	// To handle http delete calls
	Delete(httpConnection) HTTPResponse
}

HTTPInterface It handles all kind of rest calls

type HTTPResponse

type HTTPResponse struct {
	Response       string
	ActualResponse ActualResponse
	// contains filtered or unexported fields
}

HTTPResponse Response from http calls

func (*HTTPResponse) ActualRespToStr

func (httpResponse *HTTPResponse) ActualRespToStr() string

func (*HTTPResponse) CodeConverter

func (httpResponse *HTTPResponse) CodeConverter() int

CodeConverter Convert actual code into appropriate user request

func (*HTTPResponse) GetError

func (httpResponse *HTTPResponse) GetError() string

GetError It will Parse error from http response It returns parsed error message if response contains either reason or message otherwise it returns entire message

func (*HTTPResponse) IsSucceeded

func (httpResponse *HTTPResponse) IsSucceeded() bool

IsSucceeded Check that made the call is scceeded or not

func (*HTTPResponse) JSON

func (httpResponse *HTTPResponse) JSON() *json.JSON

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL