diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-05-01 20:27:00 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-05-01 20:27:00 +0200 |
commit | 3fb9c66ffa0bf87cbd7cc1b5f4129f3447e94c13 (patch) | |
tree | 71f1da93e616d3511d302c7802ae2fabc850cf13 /pkg/worker/http.go | |
download | cerrado-3fb9c66ffa0bf87cbd7cc1b5f4129f3447e94c13.tar.gz cerrado-3fb9c66ffa0bf87cbd7cc1b5f4129f3447e94c13.tar.bz2 cerrado-3fb9c66ffa0bf87cbd7cc1b5f4129f3447e94c13.zip |
feat: Initial http server code
Diffstat (limited to 'pkg/worker/http.go')
-rw-r--r-- | pkg/worker/http.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pkg/worker/http.go b/pkg/worker/http.go new file mode 100644 index 0000000..1d56f86 --- /dev/null +++ b/pkg/worker/http.go @@ -0,0 +1,26 @@ +package worker + +import ( + "context" + "net/http" +) + +type ServerTask struct { + server *http.Server +} + +func NewServerTask(server *http.Server) *ServerTask { + return &ServerTask{ + server: server, + } +} + +func (self *ServerTask) Start(ctx context.Context) error { + go func() { + // nolint: errcheck + self.server.ListenAndServe() + }() + + <-ctx.Done() + return self.server.Shutdown(ctx) +} |