refactor: migrate from rice to embed.FS

This commit is contained in:
Oleg Lobanov 2021-03-09 18:59:19 +01:00
parent 0fe34ad224
commit fc5506179a
No known key found for this signature in database
GPG key ID: 7CC64E41212621B0
10 changed files with 42 additions and 140 deletions

View file

@ -1,6 +1,7 @@
package http
import (
"io/fs"
"net/http"
"github.com/gorilla/mux"
@ -14,11 +15,17 @@ type modifyRequest struct {
Which []string `json:"which"` // Answer to: which fields?
}
func NewHandler(imgSvc ImgService, fileCache FileCache, store *storage.Storage, server *settings.Server) (http.Handler, error) {
func NewHandler(
imgSvc ImgService,
fileCache FileCache,
store *storage.Storage,
server *settings.Server,
assetsFs fs.FS,
) (http.Handler, error) {
server.Clean()
r := mux.NewRouter()
index, static := getStaticHandlers(store, server)
index, static := getStaticHandlers(store, server, assetsFs)
// NOTE: This fixes the issue where it would redirect if people did not put a
// trailing slash in the end. I hate this decision since this allows some awful