lens @ f99f2bc94808d784c92ec4e58c660a8be3ed7fce

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