-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
54 lines (40 loc) · 1.28 KB
/
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
48
49
50
51
52
53
54
package main
// TODO: middleware if you don't have any cookies "github or discord", bounce back to login page
// TODO: how are you getting the cookie
import (
"fmt"
"log"
"net/http"
"os"
"path/filepath"
"time"
"github.com/getsentry/sentry-go"
"github.com/go-chi/chi"
"github.com/go-chi/chi/v5/middleware"
m "github.com/zmzlois/LinkGoGo/pkg/middleware"
"github.com/zmzlois/LinkGoGo/pkg/monitor"
"github.com/zmzlois/LinkGoGo/pkg/router"
"github.com/zmzlois/LinkGoGo/pkg/utils"
)
func main() {
port := ":3000"
fmt.Printf("Port is trying to listening on %s\n\n", port)
// Initialize sentry
monitor.SentryInit()
// Flush buffered events before the program terminates.
// Set the timeout to the maximum duration the program can afford to wait.
defer sentry.Flush(2 * time.Second)
app := chi.NewRouter()
app.Use(middleware.Logger)
app.Use(monitor.SentryHandler.Handle)
app.Use(m.PublicMiddleware)
// Serving static files: Create a route along /files that will serve contents from
// the ./data/ folder.
workDir, _ := os.Getwd()
filesDir := http.Dir(filepath.Join(workDir, "/web/assets"))
utils.FileServer(app, "/", filesDir)
// set up all the routers
router.SetupRouter(app)
log.Fatal(http.ListenAndServe(port, app))
fmt.Println("Listening on http://localhost:3000")
}