Go API Documentation

github.com/caddyserver/caddy/v2/modules/filestorage

No package summary is available.

Package

Files: 1. Third party imports: 0. Imports from organisation: 1. Tests: 0. Benchmarks: 0.

Vars

var (
	_	caddy.StorageConverter	= (*FileStorage)(nil)
	_	caddyfile.Unmarshaler	= (*FileStorage)(nil)
)

Types

FileStorage

FileStorage is a certmagic.Storage wrapper for certmagic.FileStorage.

type FileStorage struct {
	// The base path to the folder used for storage.
	Root string `json:"root,omitempty"`
}

Functions

func (*FileStorage) UnmarshalCaddyfile

UnmarshalCaddyfile sets up the storage module from Caddyfile tokens.

func (s *FileStorage) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
	if !d.Next() {
		return d.Err("expected tokens")
	}
	if d.NextArg() {
		s.Root = d.Val()
	}
	if d.NextArg() {
		return d.ArgErr()
	}
	for d.NextBlock(0) {
		switch d.Val() {
		case "root":
			if !d.NextArg() {
				return d.ArgErr()
			}
			if s.Root != "" {
				return d.Err("root already set")
			}
			s.Root = d.Val()
			if d.NextArg() {
				return d.ArgErr()
			}
		default:
			return d.Errf("unrecognized parameter '%s'", d.Val())
		}
	}
	if s.Root == "" {
		return d.Err("missing root path (to use default, omit storage config entirely)")
	}
	return nil
}

Cognitive complexity: 19, Cyclomatic complexity: 11

func (FileStorage) CaddyModule

CaddyModule returns the Caddy module information.

func (FileStorage) CaddyModule() caddy.ModuleInfo {
	return caddy.ModuleInfo{
		ID:	"caddy.storage.file_system",
		New:	func() caddy.Module { return new(FileStorage) },
	}
}

Cognitive complexity: 2, Cyclomatic complexity: 1

func (FileStorage) CertMagicStorage

CertMagicStorage converts s to a certmagic.Storage instance.

func (s FileStorage) CertMagicStorage() (certmagic.Storage, error) {
	return &certmagic.FileStorage{Path: s.Root}, nil
}

Cognitive complexity: 1, Cyclomatic complexity: 1

Uses: certmagic.FileStorage.

Private functions

func init

init ()