gorest

package module
v0.0.0-...-f9f2125 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2021 License: MIT Imports: 11 Imported by: 0

README

go-rest

Golang library for interfacing with APIs that use simple authentication. Originally built for Captain.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpRestClient

type HttpRestClient struct {
	Client      *http.Client
	RootUrl     string
	ContentType string
	Headers     map[string]string
}

Wrapper for http.Client that provides a stateful object to make HTTP requests against. Provides some boilerplate to reduce code duplication.

func NewHttpRestClient

func NewHttpRestClient(rootUrl string, contentType string, ignoreTls bool) (*HttpRestClient, error)

Creates a new HttpRestClient that will make all requests from RootUrl with the specified settings.

func (*HttpRestClient) Delete

func (h *HttpRestClient) Delete(url string) (string, error)

func (*HttpRestClient) Get

func (h *HttpRestClient) Get(url string) (string, error)

func (*HttpRestClient) Post

func (h *HttpRestClient) Post(url string, reqBody []byte) (string, error)

Performs a POST request against the specified URI and []byte body payload. Utilizes state of referenced HttpRestClient object and returns the contents of the response body in string form.

func (*HttpRestClient) PostJson

func (h *HttpRestClient) PostJson(url string, reqBody interface{}) (string, error)

func (*HttpRestClient) PostUrlEncode

func (h *HttpRestClient) PostUrlEncode(urlPath string, reqBody interface{}) (string, error)

func (*HttpRestClient) PostWithBasicAuth

func (h *HttpRestClient) PostWithBasicAuth(url string, username string, password string, reqBody []byte) (string, error)

Jump to

Keyboard shortcuts

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