tool

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package tool provides browser automation capabilities via HTTP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateURL

func ValidateURL(rawURL string) (*url.URL, error)

ValidateURL validates a URL.

Types

type BrowserOptions

type BrowserOptions struct {
	Timeout      time.Duration
	Follow       bool
	MaxRedirects int
	Headers      map[string]string
}

BrowserOptions configures browser behavior.

func DefaultBrowserOptions

func DefaultBrowserOptions() BrowserOptions

DefaultBrowserOptions returns default browser options.

type BrowserTool

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

BrowserTool provides browser automation capabilities via HTTP.

func NewBrowserTool

func NewBrowserTool(opts ...func(*BrowserOptions)) *BrowserTool

NewBrowserTool creates a new browser tool.

func (*BrowserTool) Do

func (b *BrowserTool) Do(ctx context.Context, method, urlStr string, body io.Reader) (*Response, error)

Do performs an HTTP request.

func (*BrowserTool) Get

func (b *BrowserTool) Get(ctx context.Context, urlStr string) (*Response, error)

Get performs a GET request.

func (*BrowserTool) Post

func (b *BrowserTool) Post(ctx context.Context, urlStr string, body io.Reader) (*Response, error)

Post performs a POST request.

func (*BrowserTool) SetHeader

func (b *BrowserTool) SetHeader(key, value string)

SetHeader sets a default header.

type Formatter

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

Formatter provides formatted output for browser tool results.

func NewFormatter

func NewFormatter(indent int) *Formatter

NewFormatter creates a new formatter.

func (*Formatter) FormatResponse

func (f *Formatter) FormatResponse(resp *Response) string

FormatResponse formats a response.

type Response

type Response struct {
	StatusCode    int
	Headers       http.Header
	Body          []byte
	URL           string
	RequestMethod string
}

Response represents an HTTP response.

func (*Response) IsSuccess

func (r *Response) IsSuccess() bool

IsSuccess returns true if status code is 2xx.

func (*Response) JSON

func (r *Response) JSON() (map[string]interface{}, error)

JSON attempts to parse the response body as JSON.

func (*Response) Text

func (r *Response) Text() string

Text returns the response body as text.

type WebhookTester

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

WebhookTester tests webhooks by sending test requests.

func NewWebhookTester

func NewWebhookTester(opts ...func(*BrowserOptions)) *WebhookTester

NewWebhookTester creates a new webhook tester.

func (*WebhookTester) SendTestRequest

func (w *WebhookTester) SendTestRequest(ctx context.Context, webhookURL string, payload interface{}) (*Response, error)

SendTestRequest sends a test request to a webhook URL.

func (*WebhookTester) ValidateWebhook

func (w *WebhookTester) ValidateWebhook(ctx context.Context, webhookURL string, expectedStatus int) error

ValidateWebhook validates a webhook endpoint.

Jump to

Keyboard shortcuts

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