Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BrowserSchemes ¶
func BrowserSchemes() []string
BrowserSchemes returns the list of schemes that have been registered.
func RegisterBrowser ¶
func RegisterBrowser(ctx context.Context, scheme string, init_func BrowserInitializationFunc) error
RegisterBrowser registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `Browser` instances by the `NewBrowser` method.
func RunWithOptions ¶
func RunWithOptions(ctx context.Context, opts *RunOptions) error
RunWithOptions start a local webserver and then open its URL in a target source once it (the web server) is running.
Types ¶
type Browser ¶
type Browser interface {
// OpenURL opens a given in a URL specific to the browser's implementation context.
OpenURL(context.Context, string) error
}
Browser is an interface for rendering URLs.
func NewBrowser ¶
NewBrowser returns a new `Browser` instance configured by 'uri'. The value of 'uri' is parsed as a `url.URL` and its scheme is used as the key for a corresponding `BrowserInitializationFunc` function used to instantiate the new `Browser`. It is assumed that the scheme (and initialization function) have been registered by the `RegisterBrowser` method.
type BrowserInitializationFunc ¶
BrowserInitializationFunc is a function defined by individual browser package and used to create an instance of that browser
type RunOptions ¶
type RunOptions struct {
// The hostname for the web server to listen on. If empty then "localhost" will be assumed.
Host string
// The port number for the web server to listen on. If `0` then a random port number will be assigned.
Port int
// The `http.ServeMux` that the web server should use to route requests.
Mux *http.ServeMux
// The `Browser` instance to use to open the URL pointing to the web server.
Browser Browser
}
RunOptions defines options for serving and opening a local web server
type WebBrowser ¶
type WebBrowser struct {
Browser
}
WebBrowser implements the `Browser` interface for loading URLs in a web browser.