mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-02 00:39:16 +00:00
83b90e4199
* use vfsgen instead of go-bindata * fix templates * fix fmt * vendor vsfgen
22 lines
571 B
Go
22 lines
571 B
Go
package vfsutil
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
// File implements http.FileSystem using the native file system restricted to a
|
|
// specific file served at root.
|
|
//
|
|
// While the FileSystem.Open method takes '/'-separated paths, a File's string
|
|
// value is a filename on the native file system, not a URL, so it is separated
|
|
// by filepath.Separator, which isn't necessarily '/'.
|
|
type File string
|
|
|
|
func (f File) Open(name string) (http.File, error) {
|
|
if name != "/" {
|
|
return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist}
|
|
}
|
|
return os.Open(string(f))
|
|
}
|