httpwares_testing

package
v0.0.0-...-edc8019 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPingBackStatusCode = http.StatusCreated
)

Variables

This section is empty.

Functions

func PingBackHandler

func PingBackHandler(retCode int) http.HandlerFunc

PingBackHandler is an http.Handler that pings back the request info as JSON.

Types

type MutexReadWriter

type MutexReadWriter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MutexReadWriter is a io.ReadWriter that can be read and worked on from multiple go routines.

func NewMutexReadWriter

func NewMutexReadWriter(rw io.ReadWriter) *MutexReadWriter

NewMutexReadWriter creates a new thread-safe io.ReadWriter.

func (*MutexReadWriter) Read

func (gb *MutexReadWriter) Read(p []byte) (int, error)

Read implements the io.Reader interface.

func (*MutexReadWriter) Write

func (gb *MutexReadWriter) Write(p []byte) (int, error)

Write implements the io.Writer interface.

type PingBackResponse

type PingBackResponse struct {
	ProtoMajor int               `json:"protoMajor"`
	Method     string            `json:"method"`
	UrlHost    string            `json:"urlHost"`
	UrlPath    string            `json:"urlPath"`
	HdHost     string            `json:"hdHost"`
	Headers    map[string]string `json:"headers"`
}

PingBackResponse is a JSON struct that encodes the inbound request.

func DecodePingBack

func DecodePingBack(resp *http.Response) (*PingBackResponse, error)

DecodePingBack returns a parsed PingBackResponse for assertion purposes.

type WaresTestSuite

type WaresTestSuite struct {
	suite.Suite

	ClientInLegacyHttp1Mode bool
	ServerInLegacyHttp1Mode bool
	ServerMiddleware        []httpwares.Middleware
	ClientTripperware       []httpwares.Tripperware

	Handler http.Handler

	ServerListener net.Listener
	Server         *http.Server
}

WaresTestSuite is a testify/Suite that starts a gRPC PingService server and a client.

func (*WaresTestSuite) NewClient

func (s *WaresTestSuite) NewClient() *http.Client

NewClient returns a client that dials the server for *any* address provided. It's up to you to validate that the scheme is right.

func (*WaresTestSuite) ServerAddr

func (s *WaresTestSuite) ServerAddr() string

func (*WaresTestSuite) SetupSuite

func (s *WaresTestSuite) SetupSuite()

func (*WaresTestSuite) SimpleCtx

func (s *WaresTestSuite) SimpleCtx() context.Context

func (*WaresTestSuite) TearDownSuite

func (s *WaresTestSuite) TearDownSuite()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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