You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
759 B
Go
38 lines
759 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"github.com/fvbock/endless"
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
"time"
|
|
"uploader/global"
|
|
"uploader/initialize"
|
|
"uploader/route"
|
|
)
|
|
|
|
func main() {
|
|
var configFilePath string
|
|
flag.StringVar(&configFilePath, "config", "./config.yaml", "配置文件")
|
|
flag.Parse()
|
|
global.Config = initialize.InitConfig(configFilePath)
|
|
global.Storage = initialize.InitStorage()
|
|
RunHttpServer()
|
|
}
|
|
|
|
func RunHttpServer() {
|
|
r := gin.Default()
|
|
s := &http.Server{
|
|
Addr: ":8080",
|
|
Handler: r,
|
|
ReadTimeout: 10 * time.Second,
|
|
WriteTimeout: 10 * time.Second,
|
|
MaxHeaderBytes: 1 << 20,
|
|
}
|
|
route.Initial(r)
|
|
err := endless.ListenAndServe(":"+global.Config.Server.Port, s.Handler)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|