func Badge(ctx *middleware.Context) { importPath := ctx.Params("*") pkg, err := models.GetPakcageByPath(importPath) if err != nil { if err == models.ErrPackageNotExist { ctx.Error(404) } else { ctx.Handle(500, "Badge", err) } return } ctx.Redirect(fmt.Sprintf("http://img.shields.io/badge/downloads-%d_total-blue.svg?style=flat", pkg.DownloadCount)) }
func Package(ctx *middleware.Context) { importPath := ctx.Params("*") _, err := models.GetPakcageByPath(importPath) if err != nil { if err == models.ErrPackageNotExist { ctx.Handle(404, "Package", nil) } else { ctx.Handle(500, "Package", err) } return } ctx.Data["Title"] = importPath ctx.Data["ImportPath"] = importPath ctx.HTML(200, "package") }