func NewServer(opts ...Option) (*Server, error) {
	s := &Server{
		initializeTimeout: DefaultInitializerTimeout,
		HTTPServer:        &http.Server{},
		registrars:        []func(mux *http.ServeMux) error{},
		isAutomaticStop:   true,
	}
	for _, opt := range opts {
		if err := opt(s); err != nil {
			return nil, err
		}
	}
	mux := http.NewServeMux()
	for _, register := range s.registrars {
		if err := register(mux); err != nil {
			return nil, err
		}
	}
	s.HTTPServer.Handler = mux
	for i, j := 0, len(s.middlewares)-1; i < j; i, j = i+1, j-1 {
		s.middlewares[i], s.middlewares[j] = s.middlewares[j], s.middlewares[i]
	}
	for _, m := range s.middlewares {
		s.HTTPServer.Handler = m(s.HTTPServer.Handler)
	}
	return s, nil
}
NewServer creates a Server from the given options. All options are processed in the order they are declared.
package server
import (
	"context"
	"net"
	"net/http"
	"sync"
	"time"
	"errors"
	"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
	"github.com/infobloxopen/atlas-app-toolkit/gateway"
	"github.com/infobloxopen/atlas-app-toolkit/health"
	"google.golang.org/grpc"
)
var (
	ErrInitializeTimeout = errors.New("initialization timed out")
	DefaultInitializerTimeout = time.Minute
)
type Server struct {
	initializers      []InitializerFunc
	initializeTimeout time.Duration
	registrars        []func(mux *http.ServeMux) error
	middlewares       []Middleware
	GRPCServer *grpc.Server
	HTTPServer *http.Server
	isAutomaticStop bool
}
type Middleware func(handler http.Handler) http.Handler
type Option func(*Server) error
type InitializerFunc func(context.Context) error