Browse Source

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".
pull/424/head
listeng 8 years ago
committed by GitHub
parent
commit
5b18cf09e7
  1. 5
      weed/server/filer_server_handlers_read.go

5
weed/server/filer_server_handlers_read.go

@ -74,8 +74,13 @@ func (fs *FilerServer) listDirectoryHandler(w http.ResponseWriter, r *http.Reque
lastFileName, lastFileName,
shouldDisplayLoadMore, shouldDisplayLoadMore,
} }
if strings.ToLower(r.Header.Get("Content-Type")) == "application/json" {
writeJsonQuiet(w, r, http.StatusOK, args)
} else {
ui.StatusTpl.Execute(w, args) ui.StatusTpl.Execute(w, args)
} }
}
func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request, isGetMethod bool) { func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request, isGetMethod bool) {
if strings.HasSuffix(r.URL.Path, "/") { if strings.HasSuffix(r.URL.Path, "/") {

Loading…
Cancel
Save