initial commit on github
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
v1 "backend/v1"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/getsentry/sentry-go"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
var router *mux.Router
|
||||
var config *v1.Config
|
||||
|
||||
func init() {
|
||||
v1.LoadPrivateConfig()
|
||||
log.Println("Private config was loaded")
|
||||
|
||||
config = v1.LoadConfig()
|
||||
log.Println("Config was loaded")
|
||||
log.Println(fmt.Sprintf("Initizalized CDN path at %v", config.CDNPath))
|
||||
log.Println(fmt.Sprintf("Initizalized CDN URL at %v", config.CDNUrl))
|
||||
|
||||
err := sentry.Init(sentry.ClientOptions{
|
||||
Dsn: "https://b4bdbdbf01b344178b6fd69920ab898c@sentry.io/1817643",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("Sentry initialization failed: %v\n", err)
|
||||
}
|
||||
|
||||
router = mux.NewRouter().StrictSlash(true)
|
||||
v1.RegisterRouters(router)
|
||||
|
||||
v1.ConnectToDB()
|
||||
}
|
||||
|
||||
func main() {
|
||||
server := http.Server{
|
||||
Addr: fmt.Sprintf("%v:%v", config.Address, config.Port),
|
||||
Handler: router,
|
||||
IdleTimeout: 120 * time.Second,
|
||||
ReadTimeout: 30 * time.Second,
|
||||
WriteTimeout: 30 * time.Second,
|
||||
}
|
||||
|
||||
log.Println(fmt.Sprintf("Staring on %v:%v", config.Address, config.Port))
|
||||
err := server.ListenAndServe()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
sentry.CaptureException(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user