websockettest

package
v0.0.0-...-155e729 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

websockettest provides a server for testing. This package is not intended for production code, and should only be used in tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(handler func(conn *websocket.Conn)) http.Handler

NewHandler returns a new http.Handler that upgrades connections and calls handler. Upon return from the handler function, the connection is automatically closed.

Types

type Server

type Server struct {
	URL string
	// contains filtered or unexported fields
}

A Server is a websocket test server listening on a system-chosen port on the local loopback interface, for use in end-to-end Websocket tests.

func NewServer

func NewServer(handler http.Handler) *Server

NewServer starts and returns a new Server. Handler must respond to websocket upgrade requests. The caller should call Close when finished, to shut it down.

func (*Server) Close

func (srv *Server) Close()

Close closes the underlying server

func (*Server) Dial

func (srv *Server) Dial(opts func(*websocket.Dialer), requestHeader http.Header) (*websocket.Conn, *http.Response)

Dial creates a new connection to the server. If connecting to the server fails (for instance because it has been shut down), panics.

Jump to

Keyboard shortcuts

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