Added Status method

This commit is contained in:
2024-03-13 16:57:36 +01:00
parent c3e549ecfd
commit 02328cb41e
5 changed files with 17 additions and 13 deletions

View File

@ -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)
}