httpserver

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TestServerHost - the test server's hostname
	TestServerHost = "localhost"

	// TestServerPort - the test server's port
	TestServerPort = 18080
)

Variables

This section is empty.

Functions

func CleanURI

func CleanURI(name string) string

CleanURI - cleans and validates the URI

func CopyHeaders

func CopyHeaders(source http.Header, dest http.Header)

CopyHeaders - copy all the headers

Types

type HTTPServer

type HTTPServer struct {
	// contains filtered or unexported fields
}

HTTPServer - the server listening for HTTP requests

func CreateNewTestHTTPServer

func CreateNewTestHTTPServer(responses []ResponseData) *HTTPServer

CreateNewTestHTTPServer - creates a new server

func NewHTTPServer

func NewHTTPServer(host string, port, channelSize int, responses []ResponseData) (*HTTPServer, error)

NewHTTPServer - creates a new HTTP listener server

func (*HTTPServer) Close

func (hl *HTTPServer) Close()

Close - closes this server

func (*HTTPServer) RequestChannel

func (hl *HTTPServer) RequestChannel() <-chan *RequestData

RequestChannel - reads from the request channel

type RequestData

type RequestData struct {
	URI     string
	Body    string
	Method  string
	Headers http.Header
}

RequestData - the request data sent to the server

func WaitForHTTPServerRequest

func WaitForHTTPServerRequest(server *HTTPServer) *RequestData

WaitForHTTPServerRequest - wait until timeout or for the server sets the request in the channel

type ResponseData

type ResponseData struct {
	RequestData
	Status int
}

ResponseData - the expected response data for each configured URI

func DoRequest

func DoRequest(request *RequestData) *ResponseData

DoRequest - does a request

func ParseResponse

func ParseResponse(res *http.Response) (*ResponseData, error)

ParseResponse - parses the response using the local struct as result

Jump to

Keyboard shortcuts

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