http

package
v0.14.0-b86ae23 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderContentLength = "Content-Length"
	HeaderContentType   = "Content-Type"
)
View Source
const (
	ContentTypeAppJSON = "application/json"
)

Variables

This section is empty.

Functions

func JoinPaths

func JoinPaths(root string, paths ...string) string

JoinPaths concatenates multiple URL path segments into one path, inserting path separation characters as required.

Types

type Pipeline

type Pipeline interface {
	Do(*Request) (*Response, error)
}

func NewPipeline

func NewPipeline() Pipeline

type Request

type Request struct {
	*http.Request
}

func NewRequest

func NewRequest(ctx context.Context, httpMethod string, endpoint string) (*Request, error)

NewRequest creates a new http.Request with the specified input.

func (*Request) EncodeAsJSON

func (req *Request) EncodeAsJSON(obj any) error

EncodeAsJSON calls encodes an object as JSON encoding with SetBody.

func (*Request) SetBody

func (req *Request) SetBody(body io.ReadSeekCloser, contentType string) error

type Response

type Response struct {
	*http.Response
}

func (*Response) DecodeJSON

func (r *Response) DecodeJSON(into interface{}) error

func (*Response) HasStatusCode

func (r *Response) HasStatusCode(statusCodes ...int) bool

HasStatusCode returns true if the Response's status code is one of the specified values.

Jump to

Keyboard shortcuts

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