-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (38 loc) · 862 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
package main
import (
"akgo/akmdc"
"akgo/config"
"akgo/db"
"akgo/env"
"akgo/exception"
"akgo/feature/auth"
"akgo/response"
"log"
"net/http"
)
func main() {
akmdc.Init()
db.InitPG()
defer db.Pg.Close()
if !config.IsRSAPrivateKey(env.PasswordPrivateKey) {
log.Fatal("Invalid private key!")
}
customServeMux := &config.CustomServeMux{DefaultServeMux: http.DefaultServeMux}
mux := config.GlobalMiddleware(customServeMux)
http.HandleFunc("/info", func(writer http.ResponseWriter, request *http.Request) {
if request.Method == http.MethodGet {
response.OkStr("App version "+env.AppVersion, writer)
} else {
exception.MethodNotAllowed(writer)
}
})
auth.AuthController()
server := http.Server{
Addr: env.ServerHost + ":" + env.ServerPort,
Handler: mux,
}
err := server.ListenAndServe()
if err != nil {
panic(err)
}
}