mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-20 00:37:57 +08:00
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".
This commit is contained in:
@@ -74,7 +74,12 @@ func (fs *FilerServer) listDirectoryHandler(w http.ResponseWriter, r *http.Reque
|
|||||||
lastFileName,
|
lastFileName,
|
||||||
shouldDisplayLoadMore,
|
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) {
|
func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request, isGetMethod bool) {
|
||||||
|
Reference in New Issue
Block a user