webview

package
v3.0.0-beta.20 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderContentLength = "Content-Length"
	HeaderContentType   = "Content-Type"
)
View Source
const RequestIDHeader = "X-Wails-Request-Id"

RequestIDHeader is a private bridge marker, removed before calling handlers.

View Source
const Webkit2MinMinorVersion = 0

Variables

This section is empty.

Functions

func CancelRequest

func CancelRequest(nativeRequest unsafe.Pointer) bool

CancelRequest cancels the request associated with a native scheme task. It returns false when the task has already completed or was never registered.

func DisableMainThreadDispatch

func DisableMainThreadDispatch()

DisableMainThreadDispatch marks the GTK main loop as stopped. After it is called, invokeOnMainSync runs callbacks inline on the calling goroutine instead of scheduling them onto the now-dead main loop, so asset-server workers that complete a request during shutdown cannot block forever waiting for a source that will never be serviced. The application layer calls this once g_application_run has returned. See issue #5631.

func RequestContext

func RequestContext(r Request) (context.Context, context.CancelFunc)

RequestContext returns the lifecycle context associated with a WebView request. Requests without a native lifecycle wrapper retain the historical background context.

Types

type Request

type Request interface {
	URL() (string, error)
	Method() (string, error)
	Header() (http.Header, error)
	Body() (io.ReadCloser, error)

	Response() ResponseWriter

	Close() error
}

func NewRequest

func NewRequest(webKitURISchemeRequest unsafe.Pointer) Request

type RequestTracker

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

RequestTracker connects browser request identities to Go contexts. A tracker belongs to one WebView; neither URLs nor native pointers identify requests.

func NewRequestTracker

func NewRequestTracker(parent context.Context) *RequestTracker

func (*RequestTracker) Cancel

func (t *RequestTracker) Cancel(id string)

Cancel also removes unclaimed requests: an abort can arrive before the WebResourceRequested callback, or prevent that callback entirely.

func (*RequestTracker) Close

func (t *RequestTracker) Close()

Close cancels all requests, including requests lacking a browser identity.

func (*RequestTracker) FailKeepalive

func (t *RequestTracker) FailKeepalive(id string)

FailKeepalive releases failed delivery once all dispatched handlers finish.

func (*RequestTracker) Start

func (t *RequestTracker) Start(id string) string

Start runs before the browser resumes an intercepted request. Redirects may reuse a network ID, so each interception receives a fresh, unguessable token.

func (*RequestTracker) StartKeepalive

func (t *RequestTracker) StartKeepalive(id string) string

StartKeepalive spans redirects and outlives the JavaScript response consumer.

func (*RequestTracker) Token

func (t *RequestTracker) Token(id string) string

Token returns the marker for a request registered before interception.

func (*RequestTracker) Wrap

func (t *RequestTracker) Wrap(r Request) Request

Wrap consumes the marker and transfers context ownership to the request. A missing nonempty token means an earlier abort (or an invalid marker), and must not resurrect the request. Closing an old redirect cannot remove its successor.

type ResponseWriter

type ResponseWriter interface {
	http.ResponseWriter

	// Finish the response and flush all data. A Finish after the request has already been finished has no effect.
	Finish() error

	// Code returns the HTTP status code of the response
	Code() int
}

A ResponseWriter interface is used by an HTTP handler to construct an HTTP response for the WebView.

Jump to

Keyboard shortcuts

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