예제 #1
0
func Static(ctx *macaron.Context) {
	if len(ctx.Params(":all")) > 0 {
		f, err := os.Open(
			path.Join(
				"docs",
				"gitea",
				"images",
				ctx.Params(":all")))

		defer f.Close()

		if err != nil {
			ctx.JSON(500, map[string]interface{}{
				"error": err.Error(),
			})

			return
		}

		if _, err = io.Copy(ctx.RW(), f); err != nil {
			ctx.JSON(500, map[string]interface{}{
				"error": err.Error(),
			})

			return
		}

		return
	}

	ctx.Error(404)
}