This repository has been archived by the owner on Sep 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
62 lines (53 loc) · 1.93 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
61
62
package main
import (
"bytes"
"fmt"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/nerina1241/osu-beatmap-mirror-api/LoadBalancer"
"github.com/nerina1241/osu-beatmap-mirror-api/Logger"
"github.com/nerina1241/osu-beatmap-mirror-api/Route"
"github.com/nerina1241/osu-beatmap-mirror-api/Settings"
"github.com/nerina1241/osu-beatmap-mirror-api/middleWareFunc"
"github.com/nerina1241/osu-beatmap-mirror-api/src"
)
var LogIO = bytes.Buffer{}
var Logbuf = bytes.Buffer{}
func init() {
asciiArt()
ch := make(chan struct{})
Settings.LoadSetting()
go src.StartIndex()
go src.LoadBancho(ch)
src.ConnectMaria()
go Logger.LoadLogger(&LogIO)
_ = <-ch
go src.RunGetBeatmapDataASBancho()
}
func asciiArt() {
fmt.Println(" _ __ _ ___ ____ ____")
fmt.Println(" / | / /__ _____(_)___ __ ______ _____ / | / __ \\/ _/")
fmt.Println(" / |/ / _ \\/ ___/ / __ \\/ / / / __ `/ __ \\ / /| | / /_/ // / ")
fmt.Println(" / /| / __/ / / / / / / /_/ / /_/ / / / / / ___ |/ ____// / ")
fmt.Println("/_/ |_/\\___/_/ /_/_/ /_/\\__, /\\__,_/_/ /_/ /_/ |_/_/ /___/ ")
fmt.Println(" /____/ ")
}
func main() {
e := echo.New()
e.HideBanner = true
e.Pre(middleware.RemoveTrailingSlash())
e.Use(
// middleware.CORSWithConfig(middleware.CORSConfig{AllowOrigins: []string{"*"}, AllowMethods: []string{echo.GET}}),
// middleware.CORS(),
middleware.RateLimiterWithConfig(middleWareFunc.RateLimiterConfig),
middleware.LoggerWithConfig(middleware.LoggerConfig{Output: &LogIO}),
middleware.RequestID(),
)
e.GET("/", Route.IndexPage)
e.GET("/u", Route.UpdateBeatmap)
e.GET("/d", Route.BeatmapDownload)
e.GET("/download", LoadBalancer.CheckServerType)
e.GET("/search", Route.Search)
e.GET("/beatmapset/:sid", Route.ApiBeatmapset)
e.Logger.Fatal(e.Start(":" + Settings.Config.Port)) // localhost:8002
}