-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
33 lines (28 loc) · 840 Bytes
/
main.go
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
27
28
29
30
31
32
33
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"github.com/marhycz/strv-go-newsletter/api"
"github.com/marhycz/strv-go-newsletter/environment"
"github.com/marhycz/strv-go-newsletter/repository/database"
"github.com/marhycz/strv-go-newsletter/repository/storage"
"github.com/marhycz/strv-go-newsletter/repository/store"
)
func main() {
// Context should be passed directly to functions, not stored in structs
// https://pkg.go.dev/context#Background
ctx := context.Background()
env := &environment.Env{
Database: database.NewConnection(ctx),
Store: store.NewConnection(ctx),
Storage: storage.NewConnection(ctx),
}
controller := api.NewController(env)
fmt.Println("starting server")
if err := http.ListenAndServe(":"+os.Getenv("API_PORT"), controller); err != nil {
log.Fatal(err.Error())
}
}