session

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOutsideHome = errors.New("path is outside home directory")

ErrOutsideHome is returned by Register when a file resolves to a path outside the user's home directory. Callers use it to surface a clear user-facing error.

Functions

func ContainWithinHome

func ContainWithinHome(home, child string) (string, bool)

ContainWithinHome reports whether child is strictly inside home. When it is, it returns child rebuilt with home's exact casing on the prefix, so derived relative paths and map keys stay stable no matter how child was cased (e.g. a lowercase Windows drive letter, or macOS symlink resolution that preserves input casing). The containment test folds case on case-insensitive platforms and is exact on case-sensitive ones (Linux).

Types

type File

type File struct {
	Token   string
	AbsPath string
	RelPath string
	Name    string
	// contains filtered or unexported fields
}

func (*File) Lock

func (f *File) Lock()

Lock and Unlock serialize read-modify-write operations on this file (saves and on-serve htmlclayid injection) so concurrent handlers cannot clobber each other.

func (*File) Unlock

func (f *File) Unlock()

type Manager

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

func NewManager

func NewManager() (*Manager, error)

func NewManagerWithHome

func NewManagerWithHome(homeDir string) *Manager

func (*Manager) AllowsAsset added in v1.1.0

func (m *Manager) AllowsAsset(absPath string) bool

AllowsAsset reports whether absPath sits under the directory of any opened file. Opening a file grants its page access to that folder tree, nothing more.

func (*Manager) HomeDir

func (m *Manager) HomeDir() string

func (*Manager) Lookup

func (m *Manager) Lookup(token string) (*File, bool)

func (*Manager) LookupByPath

func (m *Manager) LookupByPath(absPath string) (*File, bool)

func (*Manager) Register

func (m *Manager) Register(absPath string) (*File, error)

func (*Manager) RevokeAll

func (m *Manager) RevokeAll()

Jump to

Keyboard shortcuts

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