Documentation
¶
Overview ¶
Package httpcall takes boilerplate out of typical non-streaming single-roundtrip HTTP API calls.
Index ¶
- Variables
- func ShellQuote(source string) string
- type BasicAuth
- type Error
- type ErrorCategory
- type Request
- func (r *Request) Clone() *Request
- func (r *Request) Curl() string
- func (r *Request) Do() error
- func (r *Request) Init()
- func (r *Request) IsIdempotent() bool
- func (r *Request) OnFailed(f func(r *Request))
- func (r *Request) OnFinished(f func(r *Request))
- func (r *Request) OnShouldStart(f func(r *Request) error)
- func (r *Request) OnStarted(f func(r *Request))
- func (r *Request) OnValidate(f func() error)
- func (r *Request) SetHeader(key, value string)
- func (r *Request) StatusCode() int
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultMaxResponseLength int64 = 100 * 1024 * 1024 // 100 MB seems like a fine safety limit DefaultRetryDelay time.Duration = 500 * time.Millisecond )
View Source
var (
ErrResponseTooLong = errors.New("response too long")
)
Functions ¶
func ShellQuote ¶ added in v0.3.29
Types ¶
type Error ¶
type Error struct { CallID string IsNetwork bool IsRetriable bool RetryDelay time.Duration StatusCode int Type string Path string Message string RawResponseBody []byte PrintResponseBody bool Cause error Category1 *ErrorCategory Category2 *ErrorCategory }
func (*Error) AddCategory ¶
func (e *Error) AddCategory(cat *ErrorCategory) *Error
func (*Error) IsInCategory ¶
func (e *Error) IsInCategory(cat *ErrorCategory) bool
func (*Error) IsUnprocessableEntity ¶
func (*Error) ShortError ¶
type ErrorCategory ¶
type ErrorCategory struct {
Name string
}
func (*ErrorCategory) Error ¶
func (err *ErrorCategory) Error() string
type Request ¶
type Request struct { Context context.Context CallID string Method string BaseURL string Path string PathParams map[string]string QueryParams url.Values FullURLOverride string // for APIs using REST-style links, completely overrides BaseURL, Path and QueryParams Input any RawRequestBody []byte RequestBodyContentType string Headers http.Header BasicAuth BasicAuth HTTPRequest *http.Request OutputPtr any MaxResponseLength int64 HTTPClient *http.Client MaxAttempts int RetryDelay time.Duration LastRetryDelay time.Duration ShouldStart func(r *Request) error Started func(r *Request) ValidateOutput func() error ParseResponse func(r *Request) error ParseErrorResponse func(r *Request) Failed func(r *Request) Finished func(r *Request) UserObject any UserData map[string]any Attempts int HTTPResponse *http.Response RawResponseBody []byte Error *Error Duration time.Duration // contains filtered or unexported fields }
func (*Request) IsIdempotent ¶
func (*Request) OnFinished ¶
func (*Request) OnShouldStart ¶
func (*Request) OnValidate ¶
func (*Request) StatusCode ¶
Click to show internal directories.
Click to hide internal directories.