schemafs

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(abs path.Absolute) (fs.FS, error)

in the future

  • mem:// an fs stored in memory
  • http:// an fs based on http
  • https:// an fs based on https
  • ftp:// an fs based on ftp
  • zip:// an fs based on a zip file
  • tree:// an tree of just relative paths independant from content
  • db:// an fs for database connections

TODO: work in progress new schemas could be registered (or old overwritten) with the Register function.

func Register

func Register(ph Handler)

Register registers the given PathFS for the Schema that it returns There can only be one PathFS for a given Schema. It there is already a PathFS for a given Schema, the new PathFS is used instead (last wins). Schema is compiled as a regular expression and if it does not compile, it panics

Types

type Handler

type Handler interface {

	// the Schema that can be handled by the PathFS
	// it will be converted to a regular expression to match against the head of an absolute path
	Schema() string

	// GetFS receives an absolute path and returns a filesystem FS
	// that can handle the path or an error, if it could not handle it
	// for valid absolute paths with a head that starts with Schema()
	// GetFS should always return a working FS
	GetFS(abs path.Absolute) (fs.FS, error)
}

Jump to

Keyboard shortcuts

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