From 95fe745a0cf98975172e5e8fc166647c48f52c80 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 4 Jun 2018 19:28:59 -0700 Subject: [PATCH] compatible with previous json rendering --- weed/server/filer_server_handlers_read_dir.go | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/weed/server/filer_server_handlers_read_dir.go b/weed/server/filer_server_handlers_read_dir.go index a39fed3fd..e0c465461 100644 --- a/weed/server/filer_server_handlers_read_dir.go +++ b/weed/server/filer_server_handlers_read_dir.go @@ -46,25 +46,35 @@ func (fs *FilerServer) listDirectoryHandler(w http.ResponseWriter, r *http.Reque glog.V(4).Infof("listDirectory %s, last file %s, limit %d: %d items", path, lastFileName, limit, len(entries)) - args := struct { - Path string - Breadcrumbs []ui.Breadcrumb - Entries interface{} - Limit int - LastFileName string - ShouldDisplayLoadMore bool - }{ - path, - ui.ToBreadcrumb(path), - entries, - limit, - lastFileName, - shouldDisplayLoadMore, - } - if r.Header.Get("Accept") == "application/json" { - writeJsonQuiet(w, r, http.StatusOK, args) + writeJsonQuiet(w, r, http.StatusOK, struct { + Path string + Entries interface{} + Limit int + LastFileName string + ShouldDisplayLoadMore bool + }{ + path, + entries, + limit, + lastFileName, + shouldDisplayLoadMore, + }) } else { - ui.StatusTpl.Execute(w, args) + ui.StatusTpl.Execute(w, struct { + Path string + Breadcrumbs []ui.Breadcrumb + Entries interface{} + Limit int + LastFileName string + ShouldDisplayLoadMore bool + }{ + path, + ui.ToBreadcrumb(path), + entries, + limit, + lastFileName, + shouldDisplayLoadMore, + }) } }