diff --git a/directory/file.go b/directory/file.go index e44cd4d6..8596b287 100644 --- a/directory/file.go +++ b/directory/file.go @@ -239,6 +239,10 @@ func (i *Info) serveListing(w http.ResponseWriter, r *http.Request, c *config.Co page.Minimal = true } + if strings.Contains(r.Header.Get("Accept"), "application/json") { + return page.PrintAsJSON(w) + } + return page.PrintAsHTML(w, "listing") } diff --git a/directory/listing.go b/directory/listing.go index 92aeceb5..0aa87fa8 100644 --- a/directory/listing.go +++ b/directory/listing.go @@ -26,8 +26,8 @@ type Listing struct { // And which order Order string // If ≠0 then Items have been limited to that many elements - ItemsLimitedTo int - httpserver.Context + ItemsLimitedTo int + httpserver.Context `json:"-"` } // handleSortOrder gets and stores for a Listing the 'sort' and 'order',