static

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package static provides middleware for the Chi router to serve static files. This package allows detailed configuration including the static file prefix and the root directory for static files. It supports both real file systems and embedded file systems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(config Config) func(next http.Handler) http.Handler

Types

type Config

type Config struct {
	Fs            fs.FS
	Root          string
	FilePrefix    string
	CacheDuration time.Duration

	Debug  bool
	Logger Logger
}

Config struct defines the configuration for the static file serving middleware. Fs refers to the file system (which can be embedded) containing the static files. Root specifies the root directory within the file system for the static files. FilePrefix is the URL prefix used to serve static files. CacheDuration is the duration for which the static files are cached.

The Debug flag enables additional logging for troubleshooting, and Logger is an interface for a custom logging mechanism. If Logger is nil and Debug is true, a default logger is used.

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

Logger interface defines the logging mechanism. It can be implemented by any logging library that provides a Printf method. This flexibility allows users to integrate their preferred logging solution.

Jump to

Keyboard shortcuts

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