func NewServer(config *Configuration, dep *ServerDependencies) http.Server {
	router := createRouter(dep)

	router.PanicHandler = func(w http.ResponseWriter, r *http.Request, panic interface{}) {
		dep.Logger.Error("Panic error:", panic)
		dep.Logger.Error(fmt.Sprintf("Stack trace: %s: %s", panic, debug.Stack()))

		err := appError{
			ErrorType: errors.Internal.String(),
			Message:   "Server internal error",
		}

		json, _ := json.Marshal(err)

		w.WriteHeader(http.StatusInternalServerError)

		if _, err := w.Write(json); err != nil {
			errResponse(err)
		}
	}

	return http.Server{
		Addr:         config.Address,
		ReadTimeout:  config.ReadTimeout,
		WriteTimeout: config.WriteTimeout,
		Handler:      router,
	}
}
// NewServer creates an http server
NewServer creates an http server
// NewServer creates an http server
func NewServer(config *Configuration, dep *ServerDependencies) http.Server {
	router := createRouter(dep)
	router.PanicHandler = func(w http.ResponseWriter, r *http.Request, panic interface{}) {
		dep.Logger.Error("Panic error:", panic)
		dep.Logger.Error(fmt.Sprintf("Stack trace: %s: %s", panic, debug.Stack()))
		err := appError{
			ErrorType: errors.Internal.String(),
			Message:   "Server internal error",
		}
		json, _ := json.Marshal(err)
		w.WriteHeader(http.StatusInternalServerError)
		if _, err := w.Write(json); err != nil {
			errResponse(err)
		}
	}
	return http.Server{
		Addr:         config.Address,
		ReadTimeout:  config.ReadTimeout,
		WriteTimeout: config.WriteTimeout,
		Handler:      router,
	}
}
func NewServer ( config * Configuration , dep * ServerDependencies ) http . Server { router := createRouter ( dep ) router . PanicHandler = func ( w http . ResponseWriter , r * http . Request , panic interface { } ) { dep . Logger . Error ( " " , panic ) dep . Logger . Error ( fmt . Sprintf ( " " , panic , debug . Stack ( ) ) ) err := appError { ErrorType : errors . Internal . String ( ) , Message : " " , } json , _ := json . Marshal ( err ) w . WriteHeader ( http . StatusInternalServerError ) if _ , err := w . Write ( json ) ; err != nil { errResponse ( err ) } } return http . Server { Addr : config . Address , ReadTimeout : config . ReadTimeout , WriteTimeout : config . WriteTimeout , Handler : router , } }
NewServer creates an http server
NewServer creates an http server