Skip to content

proposal: http: FileServer: add json content type for directory serving #23898

@posener

Description

@posener

Proposal for the http.FileServer:

In case that the Accept request header contains application/json, and the path leads to a directory, return the content of a directory as JSON.

Reason: add a bot an easier way to parse directory content.

Similar to: NGINX has autoindex_format option that has a json argument which makes NGINX return directory listings in a json format. The returned format is a list of maps, each map contains name, type (directory/file), mtime (modify time) and files also contain size in bytes, for example:

[
{ "name":"c", "type":"directory", "mtime":"Sun, 21 Jan 2018 08:13:49 GMT" },
{ "name":"xxx", "type":"file", "mtime":"Sun, 21 Jan 2018 08:13:49 GMT", "size":17 }
]

Doesn't mean that this is a good representation, we can debate if we want to adopt it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions