Skip to content
Permalink
Browse files

Move skip case to its own function

  • Loading branch information...
Raggaer committed May 23, 2019
1 parent 64b596d commit 2abb13d4ad72910bb658aa907298fba1006e105b
Showing with 10 additions and 6 deletions.
  1. +10 −6 static.go
@@ -95,12 +95,7 @@ func LoadStaticAssets(dir string) error {

// Skip case for images
fname := ""
if strings.HasSuffix(path, ".png") ||
strings.HasSuffix(path, ".ttf") ||
strings.HasSuffix(path, ".woff") ||
strings.HasSuffix(path, ".svg") ||
strings.HasSuffix(path, ".jpg") ||
strings.HasSuffix(path, ".gif") {
if shouldSkip(path) {
fname = buildNewPath(dir, filepath.Join("static", path))
} else {
fname = buildNewPath(dir, filepath.Join("static", filepath.Dir(path), strconv.FormatInt(info.ModTime().Unix(), 10)+"_"+info.Name()+".gz"))
@@ -168,6 +163,15 @@ func LoadStaticAssets(dir string) error {
return err
}

func shouldSkip(path string) bool {
return strings.HasSuffix(path, ".png") ||
strings.HasSuffix(path, ".ttf") ||
strings.HasSuffix(path, ".woff") ||
strings.HasSuffix(path, ".svg") ||
strings.HasSuffix(path, ".jpg") ||
strings.HasSuffix(path, ".gif")
}

// Asset access the given asset by static path
func Asset(path string) string {
if gin.Mode() == gin.DebugMode {

0 comments on commit 2abb13d

Please sign in to comment.
You can’t perform that action at this time.