aboutsummaryrefslogtreecommitdiff
path: root/pkg/worker/http.go
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-05-01 20:27:00 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-05-01 20:27:00 +0200
commit3fb9c66ffa0bf87cbd7cc1b5f4129f3447e94c13 (patch)
tree71f1da93e616d3511d302c7802ae2fabc850cf13 /pkg/worker/http.go
downloadcerrado-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.go26
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)
+}