From d9c62e242854ecf5daf13f09c4162e0cb7c5247a Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Thu, 11 Aug 2016 22:19:21 +0100 Subject: [PATCH] see #16 --- directory/file.go | 4 ++++ directory/listing.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) 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',