sqlitefs

package module
v0.0.0-...-22f279e Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 10 Imported by: 0

README

SQLite FS plugin for Caddy

[!WARNING] I whipped this up quickly as a proof of concept. It is experimental and likely has bugs.

This package implements a virtual file system for Caddy using SQLite.

It expects a path to a SQLite database with at least this table in its schema:

CREATE TABLE IF NOT EXISTS "files" (
	"name" TEXT PRIMARY KEY, -- full file path compliant with: https://pkg.go.dev/io/fs#ValidPath
	"content" BLOB,          -- file bytes
	"modified" INTEGER,      -- unix timestamp of last modification
	"mode" INTEGER           -- file mode
);

It can be used like so in the Caddyfile:

file_server /database/* {
	fs sqlite data.sql
}

[!NOTE] This is not an official repository of the Caddy Web Server organization.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SQLiteFS

type SQLiteFS struct {
	DBPath string `json:"db_path,omitempty"`
	// contains filtered or unexported fields
}

SQLiteFS implements a virtual file system with a sqlite database.

func (SQLiteFS) CaddyModule

func (SQLiteFS) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (SQLiteFS) Cleanup

func (s SQLiteFS) Cleanup() error

func (SQLiteFS) Open

func (s SQLiteFS) Open(name string) (fs.File, error)

Open implements fs.FS.

func (SQLiteFS) Provision

func (s SQLiteFS) Provision(ctx caddy.Context) error

func (*SQLiteFS) UnmarshalCaddyfile

func (s *SQLiteFS) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile implements caddyfile.Unmarshaler. Syntax:

sqlite <db_path>

func (*SQLiteFS) Validate

func (s *SQLiteFS) Validate() error

Validate the SQLite connection with a ping

Jump to

Keyboard shortcuts

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