-
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: brotli precompressed assets (resolve #284)
- Loading branch information
Showing
11 changed files
with
72 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package fs | ||
|
||
import ( | ||
"io/fs" | ||
"net/http" | ||
"strings" | ||
) | ||
|
||
type ExistsFS struct { | ||
Fs fs.FS | ||
} | ||
|
||
func (efs ExistsFS) Exists(name string) bool { | ||
_, err := fs.Stat(efs.Fs, name) | ||
return err == nil | ||
} | ||
|
||
func (efs ExistsFS) Open(name string) (fs.File, error) { | ||
return efs.Fs.Open(name) | ||
} | ||
|
||
// --- | ||
|
||
type ExistsHttpFS struct { | ||
Fs ExistsFS | ||
httpFs http.FileSystem | ||
} | ||
|
||
func NewExistsHttpFs(fs ExistsFS) ExistsHttpFS { | ||
return ExistsHttpFS{ | ||
Fs: fs, | ||
httpFs: http.FS(fs), | ||
} | ||
} | ||
|
||
func (ehfs ExistsHttpFS) Exists(name string) bool { | ||
if strings.HasPrefix(name, "/") { | ||
name = name[1:] | ||
} | ||
return ehfs.Fs.Exists(name) | ||
} | ||
|
||
func (ehfs ExistsHttpFS) Open(name string) (http.File, error) { | ||
return ehfs.httpFs.Open(name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters