feat(qs2) add qs2 framework

This commit is contained in:
hexxa 2020-12-05 10:30:03 +08:00
parent 6ae65fe09b
commit 83100007e3
33 changed files with 2934 additions and 60 deletions

View file

@ -1,16 +1,41 @@
package main
import (
"github.com/ihexxa/quickshare/src/server"
"github.com/ihexxa/gocfg"
goflags "github.com/jessevdk/go-flags"
"github.com/ihexxa/quickshare/src/server"
)
var opts struct {
host string `short:"h" long:"host" description:"server hostname"`
port string `short:"f" long:"file" description:"A file"`
configs []string `short:"c" description:"config path"`
}
func main() {
cfg := gocfg.New()
_, err := goflags.Parse(&opts)
if err != nil {
panic(err)
}
cfg := gocfg.New(server.NewDefaultConfig())
if len(opts.configs) > 0 {
for _, configPath := range opts.configs {
cfg, err = cfg.Load(gocfg.JSON(configPath))
if err != nil {
panic(err)
}
}
}
srv, err := server.NewServer(cfg)
if err != nil {
panic(err)
}
srv.Start()
err = srv.Start()
if err != nil {
panic(err)
}
}