-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
41 lines (32 loc) · 718 Bytes
/
main.go
File metadata and controls
41 lines (32 loc) · 718 Bytes
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
34
35
36
37
38
39
40
41
package main
import (
"flag"
"fmt"
"net/http"
"time"
"github.com/martialanouman/femProject/internal/app"
"github.com/martialanouman/femProject/internal/routes"
)
func main() {
var port int
flag.IntVar(&port, "port", 8080, "Port to run the server on")
flag.Parse()
app, err := app.NewApplication()
if err != nil {
panic(err)
}
defer app.Db.Close()
r := routes.SetupRoutes(app)
server := &http.Server{
Addr: fmt.Sprintf(":%d", port),
Handler: r,
IdleTimeout: time.Minute,
ReadTimeout: 10 * time.Second,
WriteTimeout: 30 * time.Second,
}
app.Logger.Printf("Running App on port %d!\n", port)
err = server.ListenAndServe()
if err != nil {
app.Logger.Fatal(err)
}
}