rfs

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package rfs provides a custom http.FileSystem implementation for serving files with placeholders replaced by their corresponding values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(fs http.FileSystem, placeHolder map[string]string, regex bool) http.FileSystem

New creates a new instance of the FileSystem struct with the specified embedded http.FileSystem instance and placeholder map and returns a pointer to it.

Types

type File

type File struct {
	http.File
	// contains filtered or unexported fields
}

func (*File) Read

func (f *File) Read(p []byte) (int, error)

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (int64, error)

func (*File) Stat

func (f *File) Stat() (os.FileInfo, error)

type FileInfo

type FileInfo struct {
	// contains filtered or unexported fields
}

FileInfo is a custom implementation of the os.FileInfo interface that allows setting the size of the file.

func (*FileInfo) IsDir

func (fi *FileInfo) IsDir() bool

func (*FileInfo) ModTime

func (fi *FileInfo) ModTime() time.Time

func (*FileInfo) Mode

func (fi *FileInfo) Mode() os.FileMode

func (*FileInfo) Name

func (fi *FileInfo) Name() string

func (*FileInfo) Size

func (fi *FileInfo) Size() int64

func (*FileInfo) Sys

func (fi *FileInfo) Sys() interface{}

type FileSystem

type FileSystem struct {
	http.FileSystem
	PlaceHolderValues map[string]string // map for placeholder values
	Regex             bool
}

FileSystem is a custom struct that embeds the http.FileSystem interface and adds a PlaceHolderValues map for placeholder values

func (*FileSystem) ApplyTemplate

func (f *FileSystem) ApplyTemplate(data []byte) []byte

ApplyTemplate is a method of the FileSystem struct that replaces placeholders in the input data with their corresponding values and returns the modified data If FileSystem.Regex == false replace values by {{key}} = value

func (FileSystem) Open

func (f FileSystem) Open(name string) (http.File, error)

Open is a method of the FileSystem struct that implements the http.FileSystem interface's Open method. It returns a http.File instance representing the requested file with any placeholders in its contents replaced by their corresponding values.

Jump to

Keyboard shortcuts

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