Documentation
¶
Overview ¶
Package server provides simple tools for Go HTTP servers.
Index ¶
Examples ¶
Constants ¶
View Source
const ErrServerNotReady msg.ConstError = "server not ready"
ErrServerNotReady is returned when WaitFor times out.
Variables ¶
This section is empty.
Functions ¶
func IsReady ¶
IsReady checks to see if the specified URL can be returned correctly. A nil error return signifies the server is ready.
func WaitFor ¶
WaitFor pings server until it is actively serving requests for the specified url. If the server does not properly respond within the timeout an error is returned. A nil error return signifies the server is ready.
Example ¶
if err := IsReady(goodURL); err != nil { fmt.Printf("Not Ready 1: %s\n", err) } server := runPingService() defer server.Close() if err := WaitFor(server.URL, 100*time.Millisecond); err != nil { fmt.Printf("Not Ready 2: %s\n", err) } else { fmt.Println("Success!") }
Output: Not Ready 1: Get "http://localhost:8080/ping": dial tcp 127.0.0.1:8080: connect: connection refused Success!
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.