gohttp

package module
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: MIT Imports: 9 Imported by: 0

README

GoHTTP

Build Status Go Report Card Docs License

HTTP utilities using dependencies beyond the core lib.

Documentation

Index

Constants

View Source
const (
	HeaderContentType      = "Content-Type"
	ContentTypeAppJSON     = "application/json"
	ContentTypeAppJSONUtf8 = "application/json; charset=utf-8"
)

Variables

This section is empty.

Functions

func DoJSONSimple

func DoJSONSimple(client *http.Client, httpMethod, requrl string, headers map[string][]string, body []byte) (*http.Response, error)

func JoinAbsolute

func JoinAbsolute(elem ...string) string

JoinAbsolute performs a path.Join() while preserving two slashes after the scheme.

func URLAddQueryString

func URLAddQueryString(inputURL string, qry map[string][]string) (*url.URL, error)

Types

type ResponseInfo

type ResponseInfo struct {
	Name       string            `json:"name,omitempty"` // to distinguish from other requests
	Method     string            `json:"method,omitempty"`
	URL        string            `json:"url,omitempty"`
	StatusCode int               `json:"statusCode,omitempty"`
	Time       time.Time         `json:"time,omitempty"`
	Headers    map[string]string `json:"headers,omitempty"`
	Body       string            `json:"body,omitempty"`
}

ResponseInfo is a generic struct to handle response info.

func (*ResponseInfo) ToJSON

func (resIn *ResponseInfo) ToJSON() []byte

ToJSON returns ResponseInfo as a JSON byte array, embedding json.Marshal errors if encountered.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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