INNER CODE UNIT · Go

runHandler

movio/bramble · main.go:75

func runHandler(ctx context.Context, wg *sync.WaitGroup, name, addr string, timeouts TimeoutConfig, handler http.Handler) {
	srv := &http.Server{
		Addr:         addr,
		Handler:      handler,
		ReadTimeout:  timeouts.ReadTimeoutDuration,
		WriteTimeout: timeouts.WriteTimeoutDuration,
		IdleTimeout:  timeouts.IdleTimeoutDuration,
	}

	go func() {
		log.With("addr", addr).Info(fmt.Sprintf("serving %s handler", name))
		if err := srv.ListenAndServe(); err != http.ErrServerClosed {
			log.With("error", err).Error("server terminated unexpectedly")
			os.Exit(1)
		}
	}()

	<-ctx.Done()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…