I like that Surf is stateful. Actionable methods like Open() and Post() modify the state of the browser rather than returning some object representing the request. However I've run into some minor problems with this stateful approach. I would like to add support for tabs/processes so developers can configure the browser once, and then create any number of tabs/processes that do the actual work.
// Create and configure a new browser.
bow := surf.NewBrowser()
bow.AddRequestHeader("User-Agent", "Surfbot 1.0")
bow.SetTransport(&http.Transport{})
// Create a new tab. The tab is essentially an instance
// of Browsable, and inherits it's configuration from
// the parent browser.
tab := bow.NewTab()
err := tab.Open("http://golang.org")
if err != nil {
panic(err)
}
Still debating using the term "tab", which may be taking the browser terminology too far, but on the upside the concept behind a tab -- and how it works -- should be easily understood by developers.
The feature may be treading into "over engineered" territory. Will have to give it some thought.
I like that Surf is stateful. Actionable methods like
Open()
andPost()
modify the state of the browser rather than returning some object representing the request. However I've run into some minor problems with this stateful approach. I would like to add support for tabs/processes so developers can configure the browser once, and then create any number of tabs/processes that do the actual work.How a page is opened now:
How it would be opened with "tab" support.
Still debating using the term "tab", which may be taking the browser terminology too far, but on the upside the concept behind a tab -- and how it works -- should be easily understood by developers.
The feature may be treading into "over engineered" territory. Will have to give it some thought.