// New returns a new HTTP server.
New returns a new HTTP server.
// New returns a new HTTP server .
func New(url, certFile, keyFile string, serverIdleTimeout time.Duration, handlers ...common.HTTPHandler) *Server {
	router := mux.NewRouter()
	for _, handler := range handlers {
		logger.Infof("Registering handler for [%s]", handler.Path())
		router.HandleFunc(handler.Path(), handler.Handler()).
			Methods(handler.Method()).
			Queries(params(handler)...)
	}
	router.HandleFunc(healthCheckEndpoint, healthCheckHandler).Methods(http.MethodGet)
	handler := cors.New(
		cors.Options{
			AllowedMethods: []string{
				http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete, http.MethodOptions,
			},
			AllowedHeaders: []string{"*"},
		},
	).Handler(router)
	http2Server := &http2.Server{
		IdleTimeout: serverIdleTimeout,
		CountError: func(errType string) {
			logger.Errorf("http2 server error %s", errType)
		},
	}
	httpServ := &http.Server{
		Addr:        url,
		Handler:     h2c.NewHandler(handler, http2Server),
		IdleTimeout: serverIdleTimeout,
	}
	return &Server{
		httpServer: httpServ,
		certFile:   certFile,
		keyFile:    keyFile,
	}
}
func New ( url , certFile , keyFile string , serverIdleTimeout time . Duration , handlers ... common . HTTPHandler ) * Server { router := mux . NewRouter ( ) for _ , handler := range handlers { logger . Infof ( " " , handler . Path ( ) ) router . HandleFunc ( handler . Path ( ) , handler . Handler ( ) ) . Methods ( handler . Method ( ) ) . Queries ( params ( handler ) ... ) } router . HandleFunc ( healthCheckEndpoint , healthCheckHandler ) . Methods ( http . MethodGet ) handler := cors . New ( cors . Options { AllowedMethods : [ ] string { http . MethodGet , http . MethodPost , http . MethodPut , http . MethodDelete , http . MethodOptions , } , AllowedHeaders : [ ] string { " " } , } , ) . Handler ( router ) http2Server := & http2 . Server { IdleTimeout : serverIdleTimeout , CountError : func ( errType string ) { logger . Errorf ( " " , errType ) } , } httpServ := & http . Server { Addr : url , Handler : h2c . NewHandler ( handler , http2Server ) , IdleTimeout : serverIdleTimeout , } return & Server { httpServer : httpServ , certFile : certFile , keyFile : keyFile , } }
New returns a new HTTP server.
New returns a new HTTP server .
// add health check endpoint