caddyfsarchives

package module
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

README

caddy-fs-archives

A caddy filesystem for Caddy's file_server which allows browsing into archives supported by github.com/mholt/archives.

This is currently a direct wrapper around archives.DeepFS, and so inherits its limitations. We only go down a single level. /foo.zip can be browsed, but /foo.zip/bar.zip will return the bar.zip file.

The way that caddy file_server interacts with filesystems means one can't "download" the first archive file at all via a file_server using this filesystem, only browse the files inside that archive.

Usage:

Include as a module:

xcaddy build --with github.com/codyps/caddy-fs-archives

Define a filesystem instance, and reference that instance in file_server:

# Caddyfile
{
    # "my_files" is a name you pick for this filesystem.
    # "archives" is the type of filesystem, which corresponds to the module name "caddy.fs.archives".
    filesystem my_files archives {
        # path to the root of the filesystem. This is where Caddy will look for files to serve.
        root /srv/data
    }
}

localhost:8080 {
    file_server browse {
        # "my_files" is the name of the filesystem we defined above.
        fs my_files
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

type FS struct {
	// Root is the path to the directory containing the archives and other files
	// exposed by this filesystem. If empty, the current working directory is used.
	Root string `json:"root_path,omitempty"`
	// contains filtered or unexported fields
}

FS is a Caddy virtual filesystem module for handling archive files.

## Caddyfile example

```caddy

{
	filesystem archive_files archives {
		root /srv/data
	}
}

example.com {
	file_server browse {
		fs archive_files
	}
}

```

func (FS) CaddyModule

func (FS) CaddyModule() caddy.ModuleInfo

func (*FS) Open added in v1.0.3

func (fsys *FS) Open(name string) (fs.File, error)

Open opens name and adapts the result to the additional file contracts used by Caddy's file server. In particular, regular files must be seekable and directory listings must go through DeepFS so archives appear as directories.

func (*FS) Provision

func (fs *FS) Provision(ctx caddy.Context) error

func (*FS) ReadDir added in v1.0.3

func (fsys *FS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir returns directory entries with archives represented as directories.

func (*FS) Stat added in v1.0.3

func (fsys *FS) Stat(name string) (fs.FileInfo, error)

Stat returns information about name.

func (*FS) UnmarshalCaddyfile

func (fs *FS) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile implements caddyfile.Unmarshaler. Syntax:

archives {
	root <path>
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL