-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
60 lines (45 loc) · 1.22 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
55
56
57
58
59
60
package main
import (
"crypto/rsa"
"fmt"
"log"
"os"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/YuuinIH/arknights-is-log/internal/config"
"github.com/YuuinIH/arknights-is-log/internal/middleware"
"github.com/YuuinIH/arknights-is-log/internal/route"
)
var (
privateKey *rsa.PrivateKey
)
// @title IS-LOG Api
// @version 1.0
// @description The api of the IS-LOG.
// @contact.name YuuinIH
// @contact.email [email protected]
// @license.name MIT License
// @license.url https://opensource.org/licenses/MIT
// @securityDefinitions.apiKey JWT
// @in header
// @name Authorization
// @host localhost:8080
func main() {
app := fiber.New()
file, err := os.OpenFile("./is_log.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatalf("error opening file: %v", err)
}
defer file.Close()
app.Use(logger.New(logger.Config{
Output: file,
}))
middleware.FiberMiddleware(app)
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("OK")
})
route.SwaggerRoute(app)
route.AuthRoute(app)
route.ApiRoute(app)
log.Fatal(app.Listen(":" + fmt.Sprintf("%d", config.SERVER.HTTP_PORT)))
}