package server import ( "context" "fmt" commonUtils "git.mic.pp.ua/anderson/nettools/common" "net/http" ) func (s *Server) Run(ctx context.Context) error { tasks := make([]commonUtils.Task, 0) var mux *http.ServeMux if s.HttpListener != nil || s.HttpsListener != nil { mux = http.NewServeMux() } if s.HttpListener != nil { tasks = append(tasks, func(ctx context.Context) error { return http.Serve(s.HttpListener, mux) }) } if s.HttpsListener != nil { tasks = append(tasks, func(ctx context.Context) error { return http.ServeTLS(s.HttpsListener, mux, s.Cfg.TlsCfg.Cert, s.Cfg.TlsCfg.Key) }) } if s.GrpcListener != nil { tasks = append(tasks, func(ctx context.Context) error { return nil }) } return commonUtils.ExecTasks(ctx, 0, tasks) } func (s *Server) RunHttp(mux http.Handler) error { fmt.Println("Running HTTP server") return http.Serve(s.HttpsListener, mux) } func (s *Server) RunHttps(mux http.Handler) error { fmt.Println("Running HTTPS server") return http.ServeTLS(s.HttpsListener, mux, s.Cfg.TlsCfg.Cert, s.Cfg.TlsCfg.Key) } func (s *Server) RunGrpc() error { panic("Not implemented") return nil }