-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
57 lines (46 loc) · 1.39 KB
/
main.go
File metadata and controls
57 lines (46 loc) · 1.39 KB
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
55
56
57
package main
import (
"fmt"
"net/http"
"github.com/IzomSoftware/GinWrapper/configuration"
httpscore "github.com/IzomSoftware/GinWrapper/https/core"
"github.com/IzomSoftware/GinWrapper/logger"
"github.com/IzomSoftware/GinWrapper/responses"
"github.com/IzomSoftware/GinWrapper/storage/redis_source"
"github.com/IzomSoftware/GinWrapper/storage/sql_source"
"github.com/IzomSoftware/GinWrapper/utils/jwt_util"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
)
var (
HttpsServer httpscore.HttpsServer
)
func main() {
logger.SetupLogger("Test Website", logrus.DebugLevel)
secret, _ := jwt_util.GenerateJWTRandomSecret(32)
// Adjust as needed
configuration.DefaultConfig.Protections.JWTProtection.JWTSecret = secret
config := configuration.DefaultConfig
// setup configuration
configuration.SetupConfig("config.toml")
// Intiialize storage sources
sql_source.Init()
redis_source.Init()
// add responses
responses.Responses["home"] = &responses.Response{
Handler: func(c *gin.Context) {
c.String(http.StatusOK, "")
},
Type: "GET",
Addresses: []string{"/home"},
Protections: responses.Protections{
RateLimit: responses.RateLimitProtection{
Enabled: true,
Rate: 5,
Time: 1,
},
},
}
// first argument is templateDir and second one is assetsDir
HttpsServer.ListenAndServe(fmt.Sprintf("%s*", config.HTTPServer.TemplatesDir), config.HTTPServer.AssetsDir)
}