session

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: MIT Imports: 5 Imported by: 0

README

Session

HTTP session utility for Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dict

type Dict map[string]interface{}

Dict is a generic type to hold dictionary datatypes

type List

type List []interface{}

List is a generic type to hold list datatypes

type Session

type Session struct {
	Client  http.Client
	Headers map[string]string
}

Session is a wrapper over builtin http module from go

func NewSession

func NewSession() *Session

NewSession returs a new session instance

func (*Session) BasicAuth added in v0.0.4

func (s *Session) BasicAuth(username string, password string)

BasicAuth adds basic auth to the client headders

func (*Session) Delete

func (s *Session) Delete(url string, body *[]byte, headers *map[string]string, query *map[string]string) (*http.Response, error)

Delete resuest

func (*Session) DissableSSL added in v0.0.4

func (s *Session) DissableSSL()

DissableSSL dissables ssl verification for the client

func (*Session) Get

func (s *Session) Get(url string, headers *map[string]string, query *map[string]string) (*http.Response, error)

Get resuest

func (*Session) GetBody

func (s *Session) GetBody(resp *http.Response) (string, error)

GetBody returns the string representation of the response boddy and closes the response body buffer

func (*Session) Post

func (s *Session) Post(url string, body *[]byte, headers *map[string]string, query *map[string]string) (*http.Response, error)

Post resuest

func (*Session) Put

func (s *Session) Put(url string, body *[]byte, headers *map[string]string, query *map[string]string) (*http.Response, error)

Put resuest

func (*Session) Request

func (s *Session) Request(method string, url string, body *[]byte, headers *map[string]string, query *map[string]string) (*http.Response, error)

Request returns a http.Response object with the proper method, url, body, headers and query params

func (*Session) SetHeaders

func (s *Session) SetHeaders(req *http.Request, headers *map[string]string)

SetHeaders adds headers to the request

func (*Session) SetQueryParams

func (s *Session) SetQueryParams(req *http.Request, query *map[string]string)

SetQueryParams adds query parameter to the request. Query parameters need to be passed as a map of string to string

Jump to

Keyboard shortcuts

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