func Image(ctx *tango.Context) { token := ctx.Params().Get(":path") // split token and file ext var filePath string if i := strings.IndexRune(token, '.'); i == -1 { return } else { filePath = token[i+1:] token = token[:i] } // decode token to file path var image models.Image if err := image.DecodeToken(token); err != nil { log.Info(err) return } // file real path filePath = attachment.GenImagePath(&image) + filePath // if x-send on then set header and http status // fall back use proxy serve file if setting.ImageXSend { //ext := filepath.Ext(filePath) // TODO: //ctx.Header().ContentType(ext) ctx.Header().Set(setting.ImageXSendHeader, "/"+filePath) ctx.WriteHeader(http.StatusOK) } else { // direct serve file use go ctx.ServeFile(filePath) } }