mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
update
This commit is contained in:
parent
d9c62e2428
commit
1f660b7ecf
@ -1,6 +1,7 @@
|
||||
package directory
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
@ -225,6 +226,16 @@ func (i *Info) serveListing(w http.ResponseWriter, r *http.Request, c *config.Co
|
||||
listing.ItemsLimitedTo = limit
|
||||
}
|
||||
|
||||
if strings.Contains(r.Header.Get("Accept"), "application/json") {
|
||||
marsh, err := json.Marshal(listing)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
return w.Write(marsh)
|
||||
}
|
||||
|
||||
page := &p.Page{
|
||||
Info: &p.Info{
|
||||
Name: listing.Name,
|
||||
@ -239,10 +250,6 @@ 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")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user