Remove dependency of go-bindata (#818)

* Use new embed functionality for serving UI assets

* Use new embed functionality for serving resources. Remove dependency on go-bindata

* Remove Go 1.15
This commit is contained in:
Deluan Quintão
2021-03-12 11:06:51 -05:00
committed by GitHub
parent 5a259ef3ff
commit 2d528bbc87
22 changed files with 60 additions and 150 deletions
+3 -2
View File
@@ -2,6 +2,7 @@ package server
import (
"fmt"
"io/fs"
"net/http"
"strings"
"time"
@@ -55,12 +56,12 @@ func injectLogger(next http.Handler) http.Handler {
})
}
func robotsTXT(fs http.FileSystem) func(next http.Handler) http.Handler {
func robotsTXT(fs fs.FS) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.HasSuffix(r.URL.Path, "/robots.txt") {
r.URL.Path = "/robots.txt"
http.FileServer(fs).ServeHTTP(w, r)
http.FileServer(http.FS(fs)).ServeHTTP(w, r)
} else {
next.ServeHTTP(w, r)
}