cerrado @ 8a2461aa05895cc7828bc9619b50fa5dee5ed1f4

 1package worker
 2
 3import (
 4	"context"
 5	"net/http"
 6)
 7
 8type ServerTask struct {
 9	server *http.Server
10}
11
12func NewServerTask(server *http.Server) *ServerTask {
13	return &ServerTask{
14		server: server,
15	}
16}
17
18func (self *ServerTask) Start(ctx context.Context) error {
19	go func() {
20		// nolint: errcheck
21		self.server.ListenAndServe()
22	}()
23
24	<-ctx.Done()
25	return self.server.Shutdown(ctx)
26}