Documentation
¶
Index ¶
Constants ¶
const ( // DefaultFirstGETTimeout bounds the wait for the browser's initial GET /. DefaultFirstGETTimeout = 60 * time.Second // DefaultBeaconTimeout bounds the wait for the load beacon after the page // has been delivered; on expiry the content is considered fully delivered // and the server shuts down normally. DefaultBeaconTimeout = 15 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server hosts the standalone page and coordinates its own shutdown.
func New ¶
New creates a Server serving page. firstGETTimeout bounds the wait for the browser's initial GET /; beaconTimeout bounds the wait for the load beacon after the page has been delivered. Non-positive values fall back to the
func NewEdit ¶ added in v0.5.0
NewEdit creates a keep-alive Server for --edit: the page and the api handler are both mounted under /e/<token>/, and nothing at all is served outside that prefix.
func NewKeepAlive ¶ added in v0.5.0
NewKeepAlive creates a Server that stays up until its Wait context is cancelled: neither timeout applies and the load beacon no longer ends the session. Used by --tunnel, where the page must remain reachable for as long as the session lives. The page is built per request, so a live session serves its current state; events, when not nil, is mounted at /events.
func (*Server) Addr ¶ added in v0.5.0
Addr returns the listening address as host:port (e.g. 127.0.0.1:53187), or an empty string before Start. A tunnel needs the explicit IPv4 address, not a bare port: forwarding to "localhost" may resolve to ::1, where nothing
func (*Server) Close ¶ added in v0.5.0
Close drains the server outside its normal lifecycle, for a caller that gives up before Wait was ever reached — --tunnel does when ngrok fails to come up.
func (*Server) Path ¶ added in v0.5.0
Path returns the request path the page is served at: "/" normally, and "/e/<token>/" in edit mode. A tunnel forwards to Addr and knows nothing of the prefix, so the public URL is built by appending this.
func (*Server) Start ¶
Start listens on 127.0.0.1 with an OS-assigned port and begins serving in the background. It returns the page URL (e.g. http://127.0.0.1:53187/).
func (*Server) URL ¶ added in v0.5.0
URL returns the page URL, or an empty string before Start. In edit mode it carries the token (http://127.0.0.1:53187/e/<token>/) — the bare root serves nothing there, so this is the only address worth printing or opening.