diff options
| author | listeng <aosp@163.com> | 2016-12-26 16:49:43 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-26 16:49:43 +0800 |
| commit | 5b18cf09e7643d08f28f0e963c56474eafb35747 (patch) | |
| tree | a73f4e52540b8cb15f54e35ec1f2a35c1e92e36f | |
| parent | 6b5867ce9d5d4c3b38df963acaf609a607fc3fd3 (diff) | |
| download | seaweedfs-5b18cf09e7643d08f28f0e963c56474eafb35747.tar.xz seaweedfs-5b18cf09e7643d08f28f0e963c56474eafb35747.zip | |
Return json data when content-type is "application/json"
Before #344, the filer will return json data, and cschiano make a template that render to html. But sometimes need json data, so I add some code will return json data when content-type is "application/json".
| -rw-r--r-- | weed/server/filer_server_handlers_read.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.go index bf95e37b9..5bd59b23f 100644 --- a/weed/server/filer_server_handlers_read.go +++ b/weed/server/filer_server_handlers_read.go @@ -74,7 +74,12 @@ func (fs *FilerServer) listDirectoryHandler(w http.ResponseWriter, r *http.Reque lastFileName, shouldDisplayLoadMore, } - ui.StatusTpl.Execute(w, args) + + if strings.ToLower(r.Header.Get("Content-Type")) == "application/json" { + writeJsonQuiet(w, r, http.StatusOK, args) + } else { + ui.StatusTpl.Execute(w, args) + } } func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request, isGetMethod bool) { |
