goproxy

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: MIT Imports: 4 Imported by: 2

README

go-http-proxy

A mockable http proxy

Go Report Card

Use Info

type Gresp struct{
    Status bool
    Message string
}
req, rErr := http.NewRequest("GET", "www.google.com/test", nil)

var resp Gresp
px := GoProxy{}
p := px.New()

callSuccess, httpStatusCode := p.Do(req, &resp)
// callSuccess indicates success of call
// httpStatusCode is status of the call
// resp contains the response---  make sure to pass a pointer


Use Info Mock

type Gresp struct{
    Status bool
    Message string
}
req, rErr := http.NewRequest("GET", "www.google.com/test", nil)

var w1 http.Response
	
w1.Body = ioutil.NopCloser(bytes.NewBufferString(`{"Status":true, "Message":"All good"}`))

var resp Gresp
px := MockGoProxy{}
px.MockDoSuccess1 = true
px.MockRespCode = 200
px.MockResp = &w1

p := px.New()

callSuccess, httpStatusCode := p.Do(req, &resp)
// callSuccess indicates success of call
// httpStatusCode is status of the call
// resp contains the response---  make sure to pass a pointer


Documentation

Overview

Package goproxy ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoProxy

type GoProxy struct {
}

GoProxy GoProxy

func (*GoProxy) Do

func (p *GoProxy) Do(req *http.Request, obj any) (bool, int)

Do Do

func (*GoProxy) DoNonJSON added in v1.0.3

func (p *GoProxy) DoNonJSON(req *http.Request) (bool, int, []byte)

DoNonJSON DoNonJSON

func (*GoProxy) New

func (p *GoProxy) New() Proxy

New New proxy

type MockGoProxy

type MockGoProxy struct {
	MockDoSuccess1 bool
	MockRespCode   int
	MockResp       *http.Response
}

MockGoProxy MockGoProxy

func (*MockGoProxy) Do

func (p *MockGoProxy) Do(req *http.Request, obj any) (bool, int)

Do Do

func (*MockGoProxy) DoNonJSON added in v1.0.3

func (p *MockGoProxy) DoNonJSON(req *http.Request) (bool, int, []byte)

DoNonJSON DoNonJSON

func (*MockGoProxy) New

func (p *MockGoProxy) New() Proxy

New New proxy

type Proxy

type Proxy interface {
	Do(req *http.Request, obj any) (bool, int)
	DoNonJSON(req *http.Request) (bool, int, []byte)
}

Proxy Proxy

Jump to

Keyboard shortcuts

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