server

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockHandler

type MockHandler struct {

	// URL of the HTTP test server
	URL string

	// Content Type that will be served by the test server.
	ContentType string

	// MaxRequestsToProcess before closing the stream.
	MaxRequestsToProcess int

	// Server requires basic authorization if username is set
	BasicAuth struct {
		Username string
		Password string
	}

	// Connected notifies when the connection has been accepted and is ready
	// to send events
	Connected chan struct{}
	// contains filtered or unexported fields
}

MockHandler used to emulate an http server that follows the SSE spec

func NewMockHandler

func NewMockHandler(t *testing.T) *MockHandler

func (*MockHandler) Close

func (h *MockHandler) Close()

Close cancels both the active request being served and the underlying test HTTP server

func (*MockHandler) CloseActiveRequest

func (h *MockHandler) CloseActiveRequest(block bool)

CloseActiveRequest cancels the current request being served

func (*MockHandler) ServeHTTP

func (h *MockHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*MockHandler) WriteEvent

func (h *MockHandler) WriteEvent(event *base.MessageEvent)

func (*MockHandler) WriteRetry

func (h *MockHandler) WriteRetry(delayInMillis int, getDecoder func() *decoder.Decoder)

Jump to

Keyboard shortcuts

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