Documentation
¶
Index ¶
- Variables
- type HTTPFileServer
- type ServeFS
- func NewServeFS(fsRef fs.FS, fsPathPrefix string, contentModTime time.Time) (s *ServeFS, err error)
- func NewServeFSWithPrefix(urlPathPrefix string, fsRef fs.FS, fsPathPrefix string, ...) (s *ServeFS, err error)
- func NewServeFSWithPrefixLength(urlPathPrefixLen int, fsRef fs.FS, fsPathPrefix string, ...) (s *ServeFS, err error)
- type ServeFileSystem
- func NewServeFileSystem(contentFolderPath string) (s *ServeFileSystem, err error)
- func NewServeFileSystemWithPrefix(urlPathPrefix, contentFolderPath string) (s *ServeFileSystem, err error)
- func NewServeFileSystemWithPrefixLength(urlPathPrefixLen int, contentFolderPath string) (s *ServeFileSystem, err error)
- type ServeZipArchive
- func NewServeZipArchive(zipFilePath, zipPathPrefix, zipDefaultContentPath string) (s *ServeZipArchive, err error)
- func NewServeZipArchiveWithPrefix(urlPathPrefix, zipFilePath, zipPathPrefix, zipDefaultContentPath string) (s *ServeZipArchive, err error)
- func NewServeZipArchiveWithPrefixLength(urlPathPrefixLen int, zipFilePath, zipPathPrefix, zipDefaultContentPath string) (s *ServeZipArchive, err error)
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyContentStoragePath = errors.New("content storage path is not given")
ErrEmptyContentStoragePath indicate path to content storage is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPFileServer ¶
type HTTPFileServer interface { // ServeHTTP respond content to HTTP request `r` with given targetFileName. // The defaultFileName will be use instead if targetFileName is empty. ServeHTTP(w http.ResponseWriter, r *http.Request, defaultFileName, targetFileName string) // Close free used resources. Close() (err error) }
HTTPFileServer define interface for serving file with HTTP handlers.
type ServeFS ¶ added in v0.3.0
type ServeFS struct {
// contains filtered or unexported fields
}
ServeFS is an implementation of HTTPFileServer with fs.FS as content backend.
func NewServeFS ¶ added in v0.3.0
NewServeFS create an instance of ServeFS with fsRef, fsPathPrefix and contentModTime.
func NewServeFSWithPrefix ¶ added in v0.3.0
func NewServeFSWithPrefix( urlPathPrefix string, fsRef fs.FS, fsPathPrefix string, contentModTime time.Time) (s *ServeFS, err error)
NewServeFSWithPrefix create an instance of ServeFS with urlPathPrefix, fsRef, fsPathPrefix and contentModTime.
** CAUTION **: Prefix of URL path will NOT be check. Make sure such check is done at routing logic.
func NewServeFSWithPrefixLength ¶ added in v0.3.0
func NewServeFSWithPrefixLength( urlPathPrefixLen int, fsRef fs.FS, fsPathPrefix string, contentModTime time.Time) (s *ServeFS, err error)
NewServeFSWithPrefixLength create an instance of ServeFS with urlPathPrefixLen, fsRef, fsPathPrefix and contentModTime.
type ServeFileSystem ¶
type ServeFileSystem struct {
// contains filtered or unexported fields
}
ServeFileSystem is an implementation of HTTPFileServer with file system as content backend.
func NewServeFileSystem ¶
func NewServeFileSystem(contentFolderPath string) (s *ServeFileSystem, err error)
NewServeFileSystem create an instance of ServeFileSystem with contentFolderPath.
func NewServeFileSystemWithPrefix ¶
func NewServeFileSystemWithPrefix(urlPathPrefix, contentFolderPath string) (s *ServeFileSystem, err error)
NewServeFileSystemWithPrefix create an instance of ServeFileSystem with urlPathPrefix and contentFolderPath.
** CAUTION **: Prefix of URL path will NOT be check. Make sure such check is done at routing logic.
func NewServeFileSystemWithPrefixLength ¶
func NewServeFileSystemWithPrefixLength(urlPathPrefixLen int, contentFolderPath string) (s *ServeFileSystem, err error)
NewServeFileSystemWithPrefixLength create an instance of ServeFileSystem with urlPathPrefixLen and contentFolderPath.
func (*ServeFileSystem) Close ¶
func (s *ServeFileSystem) Close() (err error)
Close free used resources.
func (*ServeFileSystem) ServeHTTP ¶
func (s *ServeFileSystem) ServeHTTP(w http.ResponseWriter, r *http.Request, defaultFileName, targetFileName string)
type ServeZipArchive ¶
type ServeZipArchive struct {
// contains filtered or unexported fields
}
ServeZipArchive is an implementation of HTTPFileServer with a zip file as content backend.
func NewServeZipArchive ¶
func NewServeZipArchive(zipFilePath, zipPathPrefix, zipDefaultContentPath string) (s *ServeZipArchive, err error)
NewServeZipArchive create an instance of ServeFileSystem with zipFilePath, zipPathPrefix and zipDefaultContentPath.
func NewServeZipArchiveWithPrefix ¶
func NewServeZipArchiveWithPrefix(urlPathPrefix, zipFilePath, zipPathPrefix, zipDefaultContentPath string) (s *ServeZipArchive, err error)
NewServeZipArchiveWithPrefix create an instance of ServeZipArchive with urlPathPrefix, zipFilePath, zipPathPrefix and zipDefaultContentPath.
** CAUTION **: Prefix of URL path will NOT be check. Make sure such check is done at routing logic.
func NewServeZipArchiveWithPrefixLength ¶
func NewServeZipArchiveWithPrefixLength(urlPathPrefixLen int, zipFilePath, zipPathPrefix, zipDefaultContentPath string) (s *ServeZipArchive, err error)
NewServeZipArchiveWithPrefixLength create an instance of ServeZipArchive with urlPathPrefixLen, zipFilePath, zipPathPrefix and zipDefaultContentPath.
func (*ServeZipArchive) Close ¶
func (s *ServeZipArchive) Close() (err error)
Close free used resources.
func (*ServeZipArchive) ServeHTTP ¶
func (s *ServeZipArchive) ServeHTTP(w http.ResponseWriter, r *http.Request, defaultFileName, targetFileName string)