request

package module
v0.0.0-...-0170c39 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 8 Imported by: 0

README

Go Simple Request

Go

A simple lightweight http client for Go.

TODO

Add docs

Documentation

Overview

Pacakge request provides a http client which includes everything you need for simple requests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	Success interface{}
	Failure interface{}
	// contains filtered or unexported fields
}

Request is a simple http request client

func New

func New() *Request

New creates a new Request

func (*Request) AddHeader

func (r *Request) AddHeader(key, value string) *Request

AddHeader can be used to add a header for the request

func (*Request) Delete

func (r *Request) Delete(url string) *Request

Delete request

func (*Request) Execute

func (r *Request) Execute() (*Response, error)

Execute runs the request and returns a response

func (*Request) Get

func (r *Request) Get(url string) *Request

Get request

func (*Request) Head

func (r *Request) Head(url string) *Request

Head request

func (*Request) New

func (r *Request) New() *Request

New creates a new request from existing request

func (*Request) Patch

func (r *Request) Patch(url string) *Request

Patch request

func (*Request) Post

func (r *Request) Post(url string) *Request

Post request

func (*Request) Put

func (r *Request) Put(url string) *Request

Put request

func (*Request) Request

func (r *Request) Request() (*http.Request, error)

Request creates and returns and http request

func (*Request) SetBody

func (r *Request) SetBody(body interface{}) *Request

SetBody is used to set request body. Must be passed as a pointer to a struct

func (*Request) SetFailure

func (r *Request) SetFailure(failure interface{}) *Request

SetFailure is used to set a custom struct for response body unmarshalling after a failed request Must be passed as a reference

func (*Request) SetHeader

func (r *Request) SetHeader(key, value string) *Request

SetHeader can be used to set a header for the request

func (*Request) SetQuery

func (r *Request) SetQuery(query interface{}) *Request

SetQuery is used to set query params for request

func (*Request) SetSuccess

func (r *Request) SetSuccess(success interface{}) *Request

SetSuccess is used to set a custom struct for response body unmarshalling after a successful request Must be passed as a reference

type Response

type Response struct {
	StatusCode int
	Header     http.Header
	Success    interface{}
	Failure    interface{}
}

Response is a response returned from the request

Jump to

Keyboard shortcuts

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