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