Documentation ¶
Index ¶
- func GetClientIPAddress(r *http.Request) string
- func GetListenPort(hport string) string
- func GetUserAgent(r *http.Request) string
- func Listen(hport string) (net.Listener, error)
- func Serve(hport string, handler http.Handler, ...) error
- func ServerFastHTTP(hport string, handler fasthttp.RequestHandler) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetClientIPAddress ¶
func GetListenPort ¶
applications need some way to access the port TODO: this method will work only after grace.Serve is called.
func GetUserAgent ¶
func Serve ¶
func Serve(hport string, handler http.Handler, gracefulTimeout, readTimeout, writeTimeout time.Duration) error
start serving on hport. If running via socketmaster, the hport argument is ignored. Also, if a port was specified via -p, it takes precedence on hport
Example ¶
package main import ( "log" "net/http" "time" ) func main() { timeout := 1 * time.Second http.HandleFunc("/foo/bar", foobarHandler) log.Fatal(Serve(":9000", nil, timeout, timeout, timeout)) } func foobarHandler(w http.ResponseWriter, r *http.Request) { w.Write([]byte("foobar")) }
Output:
func ServerFastHTTP ¶
func ServerFastHTTP(hport string, handler fasthttp.RequestHandler) error
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.