mirror of
https://github.com/prymitive/karma
synced 2026-05-05 03:16:51 +00:00
Don't create http.FileServer on every favicon request
Setup it once and use for all requests
This commit is contained in:
16
views.go
16
views.go
@@ -4,9 +4,6 @@ import (
|
||||
"crypto/sha1"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/cloudflare/unsee/config"
|
||||
"github.com/cloudflare/unsee/models"
|
||||
"github.com/cloudflare/unsee/store"
|
||||
"io"
|
||||
"net/http"
|
||||
"sort"
|
||||
@@ -14,10 +11,19 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/cloudflare/unsee/config"
|
||||
"github.com/cloudflare/unsee/models"
|
||||
"github.com/cloudflare/unsee/store"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
// needed for serving favicon from binary assets
|
||||
faviconFileServer = http.FileServer(newBinaryFileSystem("static"))
|
||||
)
|
||||
|
||||
func boolInSlice(boolArray []bool, value bool) bool {
|
||||
for _, s := range boolArray {
|
||||
if s == value {
|
||||
@@ -262,7 +268,5 @@ func autocomplete(c *gin.Context) {
|
||||
}
|
||||
|
||||
func favicon(c *gin.Context) {
|
||||
fs := newBinaryFileSystem("static")
|
||||
fileserver := http.FileServer(fs)
|
||||
fileserver.ServeHTTP(c.Writer, c.Request)
|
||||
faviconFileServer.ServeHTTP(c.Writer, c.Request)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user