Added Status method
This commit is contained in:
@ -2,7 +2,6 @@ package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
@ -70,7 +69,7 @@ func (server *Server) ServeHTTP(response http.ResponseWriter, request *http.Requ
|
||||
}
|
||||
|
||||
// Run starts the server on the given address.
|
||||
func (server *Server) Run(address string) {
|
||||
func (server *Server) Run(address string) error {
|
||||
srv := &http.Server{
|
||||
Addr: address,
|
||||
Handler: server,
|
||||
@ -83,8 +82,7 @@ func (server *Server) Run(address string) {
|
||||
listener, err := net.Listen("tcp", address)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
go srv.Serve(listener)
|
||||
@ -96,5 +94,5 @@ func (server *Server) Run(address string) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), server.Config.Timeout.Shutdown)
|
||||
defer cancel()
|
||||
|
||||
srv.Shutdown(ctx)
|
||||
return srv.Shutdown(ctx)
|
||||
}
|
||||
|
Reference in New Issue
Block a user