Skip to content

Commit

Permalink
UI fs as param
Browse files Browse the repository at this point in the history
  • Loading branch information
vcastellm committed Apr 1, 2024
1 parent a2face7 commit 5ffe0ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dkron/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (h *HTTPTransport) ServeHTTP() {

h.APIRoutes(rootPath)
if h.agent.config.UI {
h.UI(rootPath)
h.UI(rootPath, uiDist)
}

h.logger.WithFields(logrus.Fields{
Expand Down
8 changes: 4 additions & 4 deletions dkron/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"embed"
"fmt"
"html/template"
"io"
"io/fs"
"io/ioutil"
"net/http"
"strings"

Expand All @@ -18,7 +18,7 @@ const uiPathPrefix = "ui/"
var uiDist embed.FS

// UI registers UI specific routes on the gin RouterGroup.
func (h *HTTPTransport) UI(r *gin.RouterGroup) {
func (h *HTTPTransport) UI(r *gin.RouterGroup, uifs embed.FS) {
// If we are visiting from a browser redirect to the dashboard
r.GET("/", func(c *gin.Context) {
switch c.NegotiateFormat(gin.MIMEHTML) {
Expand All @@ -31,15 +31,15 @@ func (h *HTTPTransport) UI(r *gin.RouterGroup) {

ui := r.Group("/" + uiPathPrefix)

assets, err := fs.Sub(uiDist, "ui-dist")
assets, err := fs.Sub(uifs, "ui-dist")
if err != nil {
h.logger.Fatal(err)
}
a, err := assets.Open("index.html")
if err != nil {
h.logger.Fatal(err)
}
b, err := ioutil.ReadAll(a)
b, err := io.ReadAll(a)
if err != nil {
h.logger.Fatal(err)
}
Expand Down

0 comments on commit 5ffe0ec

Please sign in to comment.