Пример #1
0
// Run runs the setup server which is used to configure the application on the
// first run or when the -i/--initial option is used.
func Run() {
	var err error
	tbox, _ := rice.FindBox("templates")
	abox, _ := rice.FindBox("assets")

	gin.SetMode(gin.ReleaseMode)
	r := gin.New()
	r.Use(gin.Recovery())
	if err = utils.InitAssetsTemplates(r, tbox, abox, false, "setup.html"); err != nil {
		log.Fatal(err)
	}
	r.GET("/", index)
	r.POST("/", configure)
	fmt.Println("Please go to http://127.0.0.1:8008 to setup goploader.")
	r.Run(":8008")
}
Пример #2
0
// Setup creates the gin Engine
func Setup(tbox, abox *rice.Box) (*gin.Engine, error) {
	var err error

	gin.SetMode(gin.ReleaseMode)
	r := gin.New()
	r.Use(gin.Recovery())
	if !conf.C.NoWeb {
		if err = utils.InitAssetsTemplates(r, tbox, abox, true, "index.html"); err != nil {
			return nil, err
		}
		r.Static("/releases", "releases")
		r.GET("/", views.Index)
	}
	if conf.C.DisableEncryption {
		r.POST("/", views.Create)
		r.GET("/v/:uniuri", views.View)
		r.HEAD("/v/:uniuri", views.Head)
	} else {
		r.POST("/", views.CreateC)
		r.GET("/v/:uniuri/:key", views.ViewC)
		r.HEAD("/v/:uniuri/:key", views.HeadC)
	}
	return r, nil
}