-
Notifications
You must be signed in to change notification settings - Fork 0
/
goflet.go
64 lines (52 loc) · 1.94 KB
/
goflet.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
61
62
63
64
// Package main provides the entry point for the application
package main
import (
"github.com/vvbbnn00/goflet/base"
"github.com/vvbbnn00/goflet/config"
"github.com/vvbbnn00/goflet/route"
"github.com/vvbbnn00/goflet/task"
"github.com/vvbbnn00/goflet/util/log"
)
// @title Goflet API
// @version unknown
// @description Goflet is a lightweight file upload and download service written in Go.
// @contact.name vvbbnn00
// @contact.url https://github.com/vvbbnn00/goflet
// @contact.email [email protected]
// @license.name MIT
// @license.url https://opensource.org/licenses/MIT
// @BasePath /
// @securityDefinitions.apikey Authorization
// @in header
// @name Authorization
// @description You need to provide a valid jwt token in the header, in headers, you should provide a key-value pair like this: Authorization: Bearer xxxxxx; The token has the same effect as the token in the query string, but it is more secure than the token in the query string. Or you can just provide the token in the query string, like this: ?token=xxxxxx. More info about jwt: https://github.com/vvbbnn00/goflet?tab=readme-ov-file#authentication-method
// @externalDocs.description OpenAPI
// @externalDocs.url https://swagger.io/resources/open-api/
func main() {
base.PrintBanner()
gofletCfg := config.GofletCfg
httpConfig := gofletCfg.HTTPConfig
router := route.RegisterRoutes()
endpoint := gofletCfg.GetEndpoint()
// Start the HTTP and HTTPS servers
if *httpConfig.HTTPSConfig.Enabled {
go func() {
err := router.RunTLS(endpoint, httpConfig.HTTPSConfig.Cert, httpConfig.HTTPSConfig.Key)
if err != nil {
panic(err)
}
log.Infof("HTTPS server started on %s", endpoint)
}()
} else {
go func() {
err := router.Run(endpoint)
if err != nil {
panic(err)
}
log.Infof("HTTP server started on %s", endpoint)
}()
}
task.RunScheduledTask()
// Wait for keyboard interrupt to stop the servers
select {}
}