-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (37 loc) · 772 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"log"
"net/http"
"os"
"time"
"./controllers"
_ "github.com/go-sql-driver/mysql"
)
const (
defaultPort = "8008"
idleTimeout = 30 * time.Second
writeTimeout = 180 * time.Second
readHeaderTimeout = 10 * time.Second
readTimeout = 10 * time.Second
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = defaultPort
}
log.Println("port:", port)
// route
handler := controllers.New()
server := &http.Server{
Addr: "0.0.0.0:" + port,
Handler: handler,
IdleTimeout: idleTimeout,
WriteTimeout: writeTimeout,
ReadHeaderTimeout: readHeaderTimeout,
ReadTimeout: readTimeout,
}
err := server.ListenAndServe()
if err != nil {
log.Println("ERR ListenAndServe:", err)
}
}