Ejemplo n.º 1
0
func (this *PluginController) Get() {
	logger.Log(this.Ctx.Request.Host, this.Ctx.Request.Referer(), "packages", "")
	this.Ctx.Output.Header("Content-Type", "application/json")
	json, err := ioutil.ReadFile(beego.AppConfig.String("storagePath") + "packages/packages.json")
	if err != nil {
		this.Ctx.Output.Body([]byte(`{"packages": []}`))
	} else {
		this.Ctx.Output.Body(json)
	}
	this.StopRun()
}
Ejemplo n.º 2
0
func (this *DownloadController) Get() {
	plugin := this.GetString(":plugin")
	version := this.GetString(":version")
	file := beego.AppConfig.String("storagePath") + "/archive/" + plugin + "/" + plugin + "-" + version + ".zip"
	logger.Log(this.Ctx.Request.Host, this.Ctx.Request.Referer(), "download", plugin+"/"+version)
	bytes, err := ioutil.ReadFile(file)
	if err != nil {
		this.Ctx.Output.SetStatus(404)
		this.StopRun()
	}
	this.Ctx.Output.Header("Content-Disposition", `attachment; filename="`+plugin+"-"+version+`.zip"`)
	this.Ctx.Output.Body(bytes)
	this.StopRun()
}
Ejemplo n.º 3
0
func (this *PluginController) Post() {
	name := this.GetString("name")
	logger.Log(this.Ctx.Request.Host, this.Ctx.Request.Referer(), "check", name)
	result := struct {
		Existed bool `json:"existed"`
	}{true}
	if name == "" {
		result.Existed = true
	} else {
		if models.IsPluginExisted(name) {
			result.Existed = true
		} else {
			result.Existed = false
		}
	}
	this.Data["json"] = result
	this.ServeJson()
	this.StopRun()
}