-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
43 lines (37 loc) · 828 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
package main
import (
"log"
"net/http"
"os"
"time"
"github.com/KulwinderSingh07/POW-Blockchain/controllers"
"github.com/KulwinderSingh07/POW-Blockchain/model"
"github.com/KulwinderSingh07/POW-Blockchain/routes"
"github.com/joho/godotenv"
)
var NewBlock model.Block
var Blockchain []model.Block
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal(err)
}
controllers.Blockinitalizer()
log.Fatal(run())
}
func run() error {
mux := routes.CreateMuxRoutes()
httpPort := os.Getenv("PORT")
log.Println("Http server Listening on port :", httpPort)
s := &http.Server{
Addr: ":" + httpPort,
Handler: mux,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
if err := s.ListenAndServe(); err != nil {
return err
}
return nil
}