handle addr when port is passed in host:port format in the StartServer func (#2747)
Signed-off-by: Nikhil Sharma <nikhilsharma230303@gmail.com>
This commit is contained in:
@@ -4,13 +4,17 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func StartServer(ctx context.Context, log *zap.Logger, svc string, port string, handler http.Handler) {
|
func StartServer(ctx context.Context, log *zap.Logger, svc string, port string, handler http.Handler) {
|
||||||
|
if !strings.Contains(port, ":") {
|
||||||
|
port = fmt.Sprintf(":%s", port)
|
||||||
|
}
|
||||||
server := http.Server{
|
server := http.Server{
|
||||||
Addr: fmt.Sprintf(":%s", port),
|
Addr: port,
|
||||||
Handler: handler,
|
Handler: handler,
|
||||||
}
|
}
|
||||||
l := log.With(zap.String("service", svc), zap.String("addr", server.Addr))
|
l := log.With(zap.String("service", svc), zap.String("addr", server.Addr))
|
||||||
|
|||||||
Reference in New Issue
Block a user