ws

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package ws provides a test WebSocket server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CDPDefaultHandler

func CDPDefaultHandler(conn *websocket.Conn, msg *cdproto.Message, writeCh chan cdproto.Message, done chan struct{})

CDPDefaultHandler is a default handler for the CDP WS server.

func WithCDPHandler

func WithCDPHandler(
	path string,
	fn func(conn *websocket.Conn, msg *cdproto.Message, writeCh chan cdproto.Message, done chan struct{}),
	cmdsReceived *[]cdproto.MethodType,
) func(*Server)

WithCDPHandler attaches a custom CDP handler function to Server.

func WithClosureAbnormalHandler

func WithClosureAbnormalHandler(path string) func(*Server)

WithClosureAbnormalHandler attaches an abnormal closure behavior to Server.

func WithEchoHandler

func WithEchoHandler(path string) func(*Server)

WithEchoHandler attaches an echo handler to Server.

Types

type Server

type Server struct {
	Mux           *http.ServeMux
	ServerHTTP    *httptest.Server
	Dialer        *k6netext.Dialer
	HTTPTransport *http.Transport
	Context       context.Context
	// contains filtered or unexported fields
}

Server can be used as a test alternative to a real CDP compatible browser.

func NewServer

func NewServer(t testing.TB, opts ...func(*Server)) *Server

NewServer returns a fully configured and running WS test server.

Jump to

Keyboard shortcuts

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