Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
func (*Server) ListenAndServe ¶
ListenAndServe listens on the TCP network address s.Addr and then calls Serve to handle requests on incoming connections.
Farther it listens context Done channel and then calls Shutdown for the http server
Example ¶
srv := Server{ Mux: http.NewServeMux(), Addr: ":8111", } srv.SetSignals(os.Interrupt, syscall.SIGTERM) c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, syscall.SIGTERM) // starting server go func() { _ = srv.ListenAndServe(context.Background()) }() // sending the signal time.Sleep(time.Microsecond * 200) _ = syscall.Kill(syscall.Getpid(), syscall.SIGTERM) <-c
Output:
Click to show internal directories.
Click to hide internal directories.